You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it is understandable that there is no correct way to infer a name for these parameters, it would be better if the generation failed with an error in such cases rather than silently generating invalid interface.
However, if we try to use named parameters, more problems surface:
insert into test (email, expire_at)
values (@email, unixepoch(current_timestamp) + @expire_in_secs) ;
Now the generated generated interface uses named fields (even if the type is almost always any) but the way it binds parameters is not correct:
exportconstinsertTestQuery=`-- name: InsertTest :execinsert into test (email, expire_at)values (?1, unixepoch(current_timestamp) + ?2)`;exportinterfaceInsertTestArgs{email: any;expireInSecs: any|null;}exportasyncfunctioninsertTest(database: Database,args: InsertTestArgs): Promise<void>{conststmt=database.prepare(insertTestQuery);awaitstmt.run(args.email,args.expireInSecs);}
This fails with error:
Uncaught RangeError: Too many parameter values were provided
Because for named parameters better-sqlite3 expects an object of bindings. So the above should be:
Hello, thanks for maintaining this library. This is a great concept.
I am trying out the newly added better-sqlite3 in main branch. There appear to be some issues with parameter binding.
If we have a query like:
Then it generates an interface like:
While it is understandable that there is no correct way to infer a name for these parameters, it would be better if the generation failed with an error in such cases rather than silently generating invalid interface.
However, if we try to use named parameters, more problems surface:
Now the generated generated interface uses named fields (even if the type is almost always any) but the way it binds parameters is not correct:
This fails with error:
Because for named parameters better-sqlite3 expects an object of bindings. So the above should be:
The text was updated successfully, but these errors were encountered: