-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use TSL to generate TSL strings? #23
Comments
Interesting 👍 are you suggesting a e.g. something to automate this ?
|
I'm suggesting a walker [or a flag on existing sql walker] that from the example you give above, would build the self-contained string |
yes, so filing in the args in a string with '?' place holders sounds like for each arg do |
Interestingly, squirrel.Expr may provide the infrastructure to "smuggle" literals into squirrel: |
sql walker return |
OTOH, I don't understand how this now works:
Isn't |
One drawback of exposing an API accepting a pseudo-SQL query strings (parsed by TSL) is that it's tricky for clients to generate those strings with correct value quoting... We have some ad-hoc string-building code and I'm looking at more principled generation from something like an AST. In Go.
I first looked at squirrel but turns out it can't generate a self-contained SQL string. It only emits
?
placeholders, and returns a separte array of values, assuming you have a DB interface that safely takes separate template + args.This is good design but our API doesn't support that 😁, it takes a single TSL string.
So my next idea was using TSL itself to generate a TSL string! 💡
Ironically, currently sql walker uses squirrel as well, emitting
?
and separate values 😁Is this something you'd like like TSL to support — round trip from AST to a TSL string that parses to same AST? 🎋 -> 🔤 -> 🎋
This probably means having separate SQL and TSL walkers. Maybe some clever polymorphism with Sqlizer interface is possible, not sure how.
The text was updated successfully, but these errors were encountered: