mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Revert "🐛 Fixed a 500 error for incorrect fields parameter in API"
- this reverts commit 5584430ddc
until we
can investigate why tests are failing
This commit is contained in:
parent
5584430ddc
commit
8a1fd1f57f
@ -1,10 +1,5 @@
|
||||
const _ = require('lodash');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const messages = {
|
||||
couldNotUnderstandRequest: 'Could not understand request.'
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Bookshelf} Bookshelf
|
||||
@ -121,7 +116,7 @@ module.exports = function (Bookshelf) {
|
||||
* @param {Object} [unfilteredOptions]
|
||||
* @return {Promise<Bookshelf['Model']>} Single Model
|
||||
*/
|
||||
findOne: async function findOne(data, unfilteredOptions) {
|
||||
findOne: function findOne(data, unfilteredOptions) {
|
||||
const options = this.filterOptions(unfilteredOptions, 'findOne');
|
||||
data = this.filterData(data);
|
||||
const model = this.forge(data);
|
||||
@ -136,19 +131,7 @@ module.exports = function (Bookshelf) {
|
||||
options.columns = _.intersection(options.columns, this.prototype.permittedAttributes());
|
||||
}
|
||||
|
||||
try {
|
||||
return await model.fetch(options);
|
||||
} catch (err) {
|
||||
// CASE: SQL syntax is incorrect
|
||||
if (err.errno === 1054 || err.errno === 1) {
|
||||
throw new errors.BadRequestError({
|
||||
message: tpl(messages.couldNotUnderstandRequest),
|
||||
err
|
||||
});
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
return model.fetch(options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -283,14 +283,6 @@ describe('Posts API (canary)', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('throws a 400 when a non-existing field is requested', async function () {
|
||||
await request.get(localUtils.API.getApiQuery(`posts/slug/${testUtils.DataGenerator.Content.posts[0].slug}/?fields=tags`))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Add', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user