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

Fix argument types of onConflict #2635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jhecking
Copy link

@jhecking jhecking commented Apr 1, 2024

onConflict should accept any column reference, including raw() and ref() as input. This may be required to specify a conflict condition on a partial index. E.g. we use a query like this which works just fine for us:

await Resource._query()
  .insert(resources)
  .onConflict(raw(`(aka) where status != 'DELETED'`))
  .merge()

This is explicitly supported by knex: https://knexjs.org/guide/query-builder.html#onconflict

`onConflict` should accept any column reference, including `raw()` and `ref()` as input. This may be required to specify a conflict condition on a partial index, e.g. we use a query like this which works just fine for us:

```typescript
await Resource._query()
  .insert(resources)
  .onConflict(raw(`(aka) where status != 'DELETED'`))
  .merge()
```

This is explicitly supported by knex: https://knexjs.org/guide/query-builder.html#onconflict
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.

None yet

1 participant