-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implement named args for prepared statements #71
Conversation
Deploying with Cloudflare Pages
|
I'll take a look today, but don't you think that using |
It may, but I could not think of a different name to use.
|
I was thinking maybe |
One problem that I found is that I need to have a way to make tx.Stmt work, when using transactions we call |
The statement storage declaration also is not very readable, for some reason I had to declare all generics parameters, and need to know beforehand which type each query would use, including the case of the struct is used as the parameter. type storage struct {
preparedSelectStatement *bob.MappedQueryStmt[entity.Role, []entity.Role]
preparedSelectByRoleIDStatement *bob.MappedQueryStmt[entity.Role, []entity.Role]
preparedDeleteByRoleIDStatement *bob.MappedStmt
preparedUpdateStatement *bob.BoundQueryStmt[entity.Role, entity.Role, []entity.Role]
preparedInsertStatement *bob.BoundQueryStmt[entity.Role, entity.Role, []entity.Role]
preparedSelectPolicyStatement *bob.MappedQueryStmt[entity.RolePolicy, []entity.RolePolicy]
preparedDeletePolicyStatement *bob.MappedStmt
} |
I had not thought of this before. This definitely has to be made easier.
This is as-designed.
While this feels limiting, when using it anywhere in the code, it gives a certain level of confidence that the query will work as expected. |
I have added |
I think it should work, I was having some difficulties because we use some repository transaction pattern so I didn't have an |
I'm still not sure about the amount of complexity added just to be able to set the parameter values after the query generation. It is now not possible to use only the query builder for prepared queries, you are required to use the library |
See #104 |
@RangelReale I finally have some time to take a look at implementing named binds.
In my implementation, named arguments can only be used with prepared statements.
This is because being able to have named arguments is primarily for ease of reusing queries, and that is what prepared statements should be for.
Here is what I have so far: