3 ms·
I went through the first example in the README more than a few times, and found it quite difficult to make sense of... Are the query params stored in `q`? Whic
by agubelu 3y ago
I went through the first example in the README more than a few times, and found it quite difficult to make sense of...
Are the query params stored in `q`? Which is also updated when it's inserted in the query itself? Why does a `sqlbind.Dialect.default()` turn into an `str`?
And... what's the difference between that and normal parameterized queries? It just seems weirder and with a lot of side effect magic going on.
- bastawhiz 3y agoIt's not a lot of magic, but it's pretty opaque magic. The q object overloads the division operator and returns a ? and stores the "passed" value inside itself. The q object extends either a list or a dictionary to act as the set of values to pass to the parametrized query. So in effect, the slash behavior is just a spicy way to append or set (depending on which dialect option you choose).
- agubelu 3y agoNo, I can see that. It's the same as the logical OR operator | computing unions of sets. I just fail to see how this solution is better than a standard parameterized query, it feels much more opaque without any obvious upsides.