-
Notifications
You must be signed in to change notification settings - Fork 30
feat: add named params support #92
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Bilux <[email protected]>
Signed-off-by: Bilux <[email protected]>
Signed-off-by: Bilux <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqlTag and normalizeSql should probably just be combined into one function. I'd look into replacing sqlTag in the places it is used with the normalizeSql implementation. I'd keep the sqlTag naming though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would be better i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that normalizeSql should be renamed to sqlTag, and the old implementation of sqlTag should be deleted. normalizeSql can take its place.
DallasHoff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good so far.
What do you think about using export type Statement = {
sql: string;
params: unknown[] | Record<string, unknown>;
};The sqlocal/src/drivers/sqlite-memory-driver.ts Line 213 in c105867
Referenced from SQLite wasm: |
Signed-off-by: Bilux <[email protected]>
fc772d2 to
17c2228
Compare
Signed-off-by: Bilux <[email protected]>
wip: testing the sqlite/wasm Bindable typing
|
We can also export the // Use the `normalizeNamedParams` helper function
await sql('INSERT INTO groceries (name) VALUES (:name)', normalizeNamedParams({ name: 'bread' }));
// Or provide a valid binding object instead
await sql('INSERT INTO groceries (name) VALUES (:name)', { ':name': 'bread' });This provide more flexibility, but may introduce some confusion. |
|
Let's not use BindingSpec or BindableValue. Simpler types will suffice. |
|
If you finish making changes, please feel free to request re-review or remove the draft status from the PR. |
I reverted that commit.
Yes, it should be ready for review. |
|
I also left this comment last night. Did you see it and does it make sense? |
Signed-off-by: Bilux <[email protected]>
I didn't notice it. I think that would be better.
The last commit merges |
Hello,
This is a work-in-progress for #91 aiming to add support for named parameters.
I’ve added tests, and they’re all passing so far. However, the current implementation is not perfect (far from it, actually), there’s definitely room for improvement.
Any feedback or suggestions for a cleaner or more efficient approach would be very welcome.
Thank you.