RawBuilder is not "Compilable"

How one should execute RawBuilders coming from (for example)
```
since they're not "Compilable" things? I know you can pass from
```
since they're not "Compilable" things? I know you can pass from
sqlcustomsql.execute({ getExecutor: () => executor }) ``` since I have a custom executor, but why is that? Is there another way?
20 Replies
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
Kristian Notari
Kristian Notari15mo ago
sql`customsql`.execute({ getExecutor: () => executor })
sql`customsql`.execute({ getExecutor: () => executor })
this thing is valid ts/kysely code and it's working fine right now for executing sqlcustom sql queries under the hood, the rawBuilder .execute method compile itself and execute itself with the executor and the same queryId (given by its private properties) those methods are private as of now I'd like to transform a rawbuilder to a CompiledQuery at least. I'm doing:
queryExecutor.compileQuery(rawBuilder.toOperationNode(), queryId)
queryExecutor.compileQuery(rawBuilder.toOperationNode(), queryId)
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
Kristian Notari
Kristian Notari15mo ago
yeah I'm asking cause maybe there's a more than valid reason to hide them don't know 🙂
Igal
Igal15mo ago
GitHub
add RawBuilder.compile. by igalklebanov · Pull Request #365 · kos...
This PR allows consumers to compile RawBuilders and pass around their CompiledQuerys around when splitting build, compile and execute code.
Kristian Notari
Kristian Notari15mo ago
So is that going to be compatible with Compilable interface?
Igal
Igal15mo ago
not really, RawBuilder and sql template tag are "floaters" that require an external executor to compile/execute, while Compilable was created for query builders but since you're passing the return type to the sql template tag, it'll return a CompiledQuery with that type
Kristian Notari
Kristian Notari15mo ago
Yeah got it Is there a reason why there was a private #queryId used twice, once for the compilation and once for the execution inside RawBuilders?
Igal
Igal15mo ago
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
Igal
Igal15mo ago
https://github.com/koskimas/kysely/pull/176 this PR could help with split of build, compile and execute vs. plugins
GitHub
add queryId to CompiledQuery to allow async communication betwe...
does what #173 tried to achieve, but in a simpler way as suggested by @koskimas.
Igal
Igal15mo ago
Might have to revisit it
Kristian Notari
Kristian Notari15mo ago
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 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
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
Kristian Notari
Kristian Notari15mo ago
I mean, during execution you pass a queryId to the executor execute method What if that’s different from the one used during compiling? Since compiling is managed inside the raw builder
Igal
Igal15mo ago
You don't have to anymore (pending release) but yeah, query id should be part of the compiled query
Kristian Notari
Kristian Notari15mo ago
Igal vs igalk is confusing as hell 😂 sorry I thought to be speaking to the same person so far
Igal
Igal15mo ago
Same person, different devices
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
Kristian Notari
Kristian Notari15mo ago
🤯
Igal
Igal11mo ago
We've released this btw.