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

Getting error when using `_patch` method with `allowedUpsert` service option enabled. #163

Closed GVanderLugt closed 3 years ago

GVanderLugt commented 3 years ago

When using the _patch() service method that skips service level hooks I am getting an error from feathers-objection. The service has allowedUpsert enabled. If I don't use _patch and use the regular patch instead, it works fine.

The error is:

error TypeError: Cannot read property 'mergeAllowUpsert' of undefined
at Object._patch (/app/node_modules/feathers-objection/lib/index.js:882:74)

The service is configured like:

export default function (app: Application) {
  const options = {
    Model: OrderModel,
    paginate: app.get('paginate'),
    whitelist: ['$eager', '$joinEager'],
    allowedEager: '[user, items.[product, fulfillment_method], shipping_address]',
    allowedInsert: '[items, shipping_address]',
    allowedUpsert: 'shipping_address',
    eagerFilters: [
      {
        expression: 'user',
        filter: 'eagerSelects',
      },
      {
        expression: 'items.product',
        filter: 'eagerSelects',
      },
    ],
  };

  // Initialize our service with any options it requires
  app.use('/orders', new Orders(options, app));

  // Get our initialized service so that we can register hooks
  const service = app.service('orders');

  service.hooks(hooks);
}
GVanderLugt commented 3 years ago

I jumped the gun a bit on creating this issue. I tried removing the allowedUpsert configuration and the issue persists, so it's not necessarily related to that.

GVanderLugt commented 3 years ago

I realized I was a bit behind on versions for feathers-objection. After updating to the latest version I am no longer having this issue.