Support for the single/at-least-one row pattern in sqlitex.Execute
and friends.
#90
flowchartsman
started this conversation in
Ideas
Replies: 1 comment
-
I just spent a good hour trying to figure out why my very simple "does this row exist in the table?" query wasn't working. SELECT id, foo
FROM table
WHERE foo = :foo
LIMIT 1
...then I found this post. I solved it by adding a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Follow-on to #85
sqlitex.Execute
and friends are one of the nicer parts of this library, IMHO, since they provide a nice level of abstraction over the scan process without being too magical or cumbersome. I especially enjoy how well theFS
variants can coexist with packageembed
allowing for a nice separation between SQL and source, while overloading the fs path as an extra level of organization.The only rough edge from my experience is identifying queries that return a single result from those which do not. Currently, the only support for this exists in the form of
Result*
methods such assqlitex.ResultInt
, however these only work with statements, which leaves a lot of boilerplate for the user in terms of setting up query parameters. To do something similar withExecute
, the user needs toExecOptions
.ResultFunc
has been called using another value outside of the closure and an update of the value inside of the closure:This is a common enough use case that it would be great if we could automate it.
There are a couple different ways this could be done that I've proposed so far:
ResultFunc
SingleRow
family of functions that uses closures to automate the above.But there may be more, so I'd love to discuss it here.
Beta Was this translation helpful? Give feedback.
All reactions