Merge pull request #3209 from strapi/fix/filter-timestamp

Fix filters on timestamp attributes
This commit is contained in:
Jim LAURIE 2019-05-02 14:25:11 +02:00 committed by GitHub
commit c099c33d94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -834,6 +834,9 @@ module.exports = function(strapi) {
};
}
// Save all attributes (with timestamps)
target[model].allAttributes = _.clone(definition.attributes);
// Equilize tables
if (connection.options && connection.options.autoMigration !== false) {
await handler(loadedModel.tableName, definition.attributes);

View File

@ -303,6 +303,9 @@ module.exports = function(strapi) {
_.get(definition, 'options.minimize', false) === true
);
// Save all attributes (with timestamps)
target[model].allAttributes = _.clone(definition.attributes);
collection.schema.options.toObject = collection.schema.options.toJSON = {
virtuals: true,
transform: function(doc, returned, opts) {

View File

@ -5,7 +5,7 @@ const findModelByAssoc = assoc => {
return models[assoc.collection || assoc.model];
};
const isAttribute = (model, field) => _.has(model.attributes, field) || model.primaryKey === field;
const isAttribute = (model, field) => _.has(model.allAttributes, field) || model.primaryKey === field;
/**
* Returns the model, attribute name and association from a path of relation