Better support for Prepare #65
Replies: 5 comments 13 replies
-
I see a need for something like this. It actually had not occurred to me that the order of args may be unexpected for prepared statements. At first glance, I'm not totally in love with your proof-of-concept, the way to use named args doesn't seem completely intuitive to me. However, it is possible that this is the best way to make it work. I'll try to think about it, but I have a lot going on over the coming months, so this would likely not be something I tackle soon. |
Beta Was this translation helpful? Give feedback.
-
Here is my second proof-of-concept, this is the general ideia (there's a
bob.All(context.Background(), bdb, prepared.Query(map[string]any{
"offset": items[0],
"limit": items[1],
}), dataMapper) The idea is to call |
Beta Was this translation helpful? Give feedback.
-
Did a third proof-of-concept that is much simpler, but relies on global functions to be able to set the named parameters and return values compatible with the other functions. As a bonus it also works with |
Beta Was this translation helpful? Give feedback.
-
I can open a PR using this branch if you want to follow this path, so we can comment there. |
Beta Was this translation helpful? Give feedback.
-
Should be addressed by #298 |
Beta Was this translation helpful? Give feedback.
-
In the documentation about Prepare, it says to create a statement using
Prepare
and then executing the statement sending the arguments.The problem with it is that we don't have a good way to know in what order the arguments should be sent other than trial-and-error or guessing, because the query is generated.
I created a proof-of-concept (brainstorm, not production code) of creating named args that could be replaced with a map at execution time, outputting an array in the correct order.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions