Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(knex): Add support for extended operators in query builder (fixes #3377) #3578

Open
wants to merge 2 commits into
base: dove
Choose a base branch
from

Conversation

michalgm
Copy link

@michalgm michalgm commented Mar 21, 2025

This change adds the ability to define custom operators via a new extendedOperators option for the knex service constructor. This allows the use of database-specific operators that aren't included in the standard set.

  • Modified the knexify method to use both built-in and extended operators
  • Added documentation for the extendedOperators option
  • Added tests to verify the functionality with custom operators

Example usage:

const service = new KnexService({
  Model: db,
  name: 'people',
  extendedOperators: {
    $startsWith: 'LIKE',
    $fulltext: '@@'  // PostgreSQL full-text search
  }
})

This fixes #3377

This change adds the ability to define custom operators via a new
`extendedOperators` option for the knex service constructor. This allows the use of  database-specific operators that aren't included in the standard set.

- Modified the `knexify` method to use both built-in and extended operators
- Added documentation for the `extendedOperators` option
- Added tests to verify the functionality with custom operators

Example usage:
```typescript
const service = new KnexService({
  Model: db,
  name: 'people',
  extendedOperators: {
    $startsWith: 'LIKE',
    $fulltext: '@@'  // PostgreSQL full-text search
  }
})
@michalgm
Copy link
Author

I'm now realizing another approach would be to just extended OPERATORS to support everything the knex supports: https://github.com/knex/knex/blob/9bd12999907436c2ef51f786df09a9a7e8931cca/lib/formatter/wrappingFormatter.js#L9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support additional postgres operators
1 participant