objection.js icon indicating copy to clipboard operation
objection.js copied to clipboard

A few Typescript and Knex issues

Open Linksku opened this issue 2 years ago • 1 comments

Here are some misc things that I think could be changed. I've never written an open source PR before, I think it's easier if an existing contributor changed it:

  1. Knex supports objects for joins and aggregates. It's especially useful for multi-column joins:
.join(
  'foo',
  {
    'foo.col1': 'bar.col1',
    'foo.col2': 'bar.col2',
  },
)

Something like this ((table: TableRef<QB>, columns: Record<string, ColumnRef>): QB;) could be added to JoinMethod.

  1. Knex's limit now supports an additional param "skipBinding" (https://github.com/knex/knex/issues/4805). Objection's FirstOperation calls limit without skipBinding, which triggers an error in some databases (Materialize).

  2. Objection's type exports UniqueViolationError, but this actually needs to be imported from db-errors.

  3. Objection's Model type doesn't include "propertyNameToColumnName".

  4. (not a real issue) addOperation and KnexOperation aren't documented or exposed through types, but they're useful for new or custom Knex operations.

Thanks for building and maintaining this awesome library!

Linksku avatar Jan 11 '22 22:01 Linksku

Same problems here for Objection errors. In Typescript We can't do that :

import { UniqueViolationError } from 'objection';

throrin19 avatar Nov 30 '23 09:11 throrin19