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

Possible issue with checks on Postgres #5473

Open
jpruliere opened this issue Feb 2, 2023 · 0 comments
Open

Possible issue with checks on Postgres #5473

jpruliere opened this issue Feb 2, 2023 · 0 comments

Comments

@jpruliere
Copy link

Environment

Knex version: 2.4.2
Database + version: PostgreSQL 13.5
OS: Docker container postgis/postgis:latest

Bug

I am writing a migration script to add a constraint on an int column that should only accept multiples of 5 starting with 2020. I expected the check constraint to be created, but an error occured.

// inside a migration script
await knex.schema.alterTable('some_table', (t) => {
	t.check('(?? - 2020) % 5 = 0', ['horizon'], 'some_constraint_name')
})

The error :

alter table "some_table" add constraint some_constraint_name check(($1$2 - 2020) % 5 = 0) - syntax error at or near "$2"

The ?? seem to be taken separately.

I found a temporary workaround that I explained here

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

No branches or pull requests

1 participant