4 ms·
I may be misunderstanding you, but at least for the "to SQL" part I think that's just someJetStatement.DebugSql() All Jet-generated Statement objects have t
by renhanxue 2y ago
I may be misunderstanding you, but at least for the "to SQL" part I think that's just
someJetStatement.DebugSql()
All Jet-generated Statement objects have the .DebugSql() method. It returns the generated query as a string with all the bound parameters inlined[0] so you can just print it or grab it with the debugger and copypaste it into your query console.
[0]: that is, it translates the query it'd actually execute, which would look like
WHERE foo = $1
into
WHERE foo = 'bound parameter value'
with some rudimentary escaping to avoid the most obvious SQL injection problems (don't use it to actually run queries in production, obviously!!).
- pier25 2y agoThat's good but what about the other way around? I mean if I start writing a complex query in a DB client and then want to translate it to Jet.
- renhanxue 2y agoNo automated way to do that, I'm afraid. That said, most of the Jet statement builder API maps directly to SQL keywords, so it's usually straightforward. Still, some specific things are pretty awkward (CTE's come to mind).