RawBuilder is not "Compilable"

KNKristian Notari3/17/2023
How one should execute RawBuilders coming from (for example)
sql`customsql`

since they're not "Compilable" things? I know you can pass from
sql`customsql`.execute({ getExecutor: () => executor })

since I have a custom executor, but why is that? Is there another way?
UUUnknown User3/17/2023
Message Not Public
Sign In & Join Server To View
KNKristian Notari3/17/2023
sql`customsql`.execute({ getExecutor: () => executor })

this thing is valid ts/kysely code and it's working fine right now for executing sqlcustom sql queries
KNKristian Notari3/17/2023
under the hood, the rawBuilder .execute method compile itself and execute itself with the executor and the same queryId (given by its private properties)
KNKristian Notari3/17/2023
those methods are private as of now
KNKristian Notari3/17/2023
I'd like to transform a rawbuilder to a CompiledQuery at least. I'm doing:
queryExecutor.compileQuery(rawBuilder.toOperationNode(), queryId)
UUUnknown User3/17/2023
Message Not Public
Sign In & Join Server To View
KNKristian Notari3/17/2023
yeah I'm asking cause maybe there's a more than valid reason to hide them
KNKristian Notari3/17/2023
don't know 🙂
KNKristian Notari3/18/2023
So is that going to be compatible with Compilable interface?
IIgal3/18/2023
not really, RawBuilder and sql template tag are "floaters" that require an external executor to compile/execute, while Compilable was created for query builders
IIgal3/18/2023
but since you're passing the return type to the sql template tag, it'll return a CompiledQuery with that type
KNKristian Notari3/18/2023
Yeah got it
KNKristian Notari3/18/2023
Is there a reason why there was a private #queryId used twice, once for the compilation and once for the execution inside RawBuilders?
IIgal3/18/2023
query id is passed around mainly for the plugin system which consists of 2 steps:

pre-query transformQuery
post-query transformResult

the id allows to communicate between the steps using WeakMaps
IIgal3/18/2023
https://github.com/koskimas/kysely/pull/176 this PR could help with split of build, compile and execute vs. plugins
IIgal3/18/2023
Might have to revisit it
KNKristian Notari3/18/2023
Cause I got it working with my custom executor by self passing the executor to RawBuilder.execute. Now that I’m using toOperationNode I took care of using the same queryId for both compiling and executing, just to be sure and follow the private internal behavior of RawBuilders
KNKristian Notari3/18/2023
So if RawBuilder get its own public compile then we should take care of using the same queryId then? Not sure how “secure” that would be
UUUnknown User3/18/2023
Message Not Public
Sign In & Join Server To View
KNKristian Notari3/18/2023
I mean, during execution you pass a queryId to the executor execute method
KNKristian Notari3/18/2023
What if that’s different from the one used during compiling? Since compiling is managed inside the raw builder
IIgal3/18/2023
You don't have to anymore (pending release)
IIgal3/18/2023
but yeah, query id should be part of the compiled query
KNKristian Notari3/18/2023
Igal vs igalk is confusing as hell 😂 sorry I thought to be speaking to the same person so far
IIgal3/19/2023
Same person, different devices
UUUnknown User3/19/2023
Message Not Public
Sign In & Join Server To View
KNKristian Notari3/19/2023
🤯