feathersjs-ecosystem / feathers-objection

Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
MIT License
98 stars 48 forks source link

Handle missing top-level jsonSchema.properties in objectify() #149

Closed alex-all3dp closed 3 years ago

alex-all3dp commented 3 years ago

If the jsonSchema of an Objection model does not contain a top-level properties field, objectify() will currently fail with errors like Cannot read property 'MyModel.id' of undefined. This happens for instance when the count query after a create operation is executed.

Example schema:

{
      type: 'object',
      allOf: [
        { 
           properties: { id: {type: 'string' }
        },
        {...}
    ]
}

The proposed sanity check allows to gracefully support JSON schemas that have use schema combination via anyOf, allOf etc. at the top-level

dekelev commented 3 years ago

Thanks @alex-all3dp , it's released in v7.1.7