Skip to content

Allow positional parameters #40

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

Closed
thanhnguyen2187 opened this issue Feb 11, 2024 · 2 comments · Fixed by #41
Closed

Allow positional parameters #40

thanhnguyen2187 opened this issue Feb 11, 2024 · 2 comments · Fixed by #41
Assignees
Labels
enhancement New feature or request

Comments

@thanhnguyen2187
Copy link
Contributor

For example, we have this query:

INSERT INTO table VALUES (?, ?, ?)

Binding values to those questions marks are not supported by ws4sqlite (#39).

I know the documentation wrote that:

If the query needs to be parametrized, named parameters can be defined in the statement using SQLite (e.g. :id or @id), and the proper values for them must be specified here.

However, it is a syntax supported by SQLite itself:

In the SQL statement text input to sqlite3_prepare_v2() and its variants, literals may be replaced by a parameter that matches one of following templates:

?
?NNN
:VVV
@VVV
$VVV 

In the templates above, NNN represents an integer literal, and VVV represents an alphanumeric identifier. The values of these parameters (also called "host parameter names" or "SQL parameters") can be set using the sqlite3_bind_*() routines defined here.

@thanhnguyen2187
Copy link
Contributor Author

thanhnguyen2187 commented Feb 11, 2024

More context on why I need this: I was wrapping Drizzle around ws4sqlite/sqliterg, and Drizzle's wrapper seems to only support positional parameters.

What do you think, @proofrock? Is there any deeper technical issue on why it's hard to support this?

@proofrock
Copy link
Owner

Not hard to support, actually; it's just that ws4sqlite doesn't mean to support everything that sqlite does. I went with the map approach because... well, I guess I liked it more. Also, allowed for a more intuitive deduplication (if you have two parameters that are the same, you just pass one, without tinkering with indexes).

Do you have an use case, or a preference? Nothing against implementing it.

@proofrock proofrock self-assigned this Feb 12, 2024
@proofrock proofrock added the enhancement New feature or request label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants