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

[TypeScript] Fix raw bindings typing #5401

Merged
merged 1 commit into from Jul 19, 2023

Conversation

kevindorchard
Copy link
Contributor

As per the documentation, the bindings param can be a single value, an array of values, or a dictionary of named binding values.

The type was incorrect, as it implied that one could bind multiple values by passing multiple parameters, rather than using an array:

// This was OK before, because TS expects (sql: string, ...bindings: RawBinding[])
// Expectation was bindings ['value for a', 'value for 'b']
// Actual was bindings ['value for a'] and the second binding was ignored
knex().raw('select * from table where a = ? and b = ?', 'value for a', 'value for b');

With the correct typing, the above code will now throw a type error "Expected 1-2 arguments, but got 3".

@coveralls
Copy link

coveralls commented Dec 23, 2022

Coverage Status

coverage: 92.797%. remained the same when pulling 6a7cd44 on kevindorchard:fix-raw-bindings-typing into ce6b591 on knex:master.

@OlivierCavadenti OlivierCavadenti merged commit 4b6a804 into knex:master Jul 19, 2023
53 checks passed
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

3 participants