Join DATE_TRUNC
Hey, sorry if this is already answered somewhere. I couldn't find anything 😦
I want to translate this part of a SQL query into Kysely
I tried this, but doesn't seem to be working
11 Replies
Hey 👋
Try this: https://kyse.link/?p=s&i=I2oKCdnuMtLMgnTfFE44
Yeah that works, thanks a lot! I'll probably ask more questions later in other threads if thats ok on 😅
Feel free to ask anything! 🙂
what's the difference on making the query with and without
ref
. Seems that the produced output is the sameCan you be more specific?
ref
can mean 2 different thingsSure, sorry about the ambiguity. In the link you shared the eb ref function is used.
However if I remove it, I get the same query
that's my bad here,
eb.fn
treats strings as refsOk, so as long as I'm inside of
eb.fn
I can use plain strings? And another question,
What's the best way to translate this?
I'm doing this, but obviously TS is complaining
yes, when referring to columns in query context.. otherwise you need to escape it (e.g.
sql.lit('some_string')
or eb.val('some_string')
)
.lit
opens you up for sql injection, so make sure you use it with care.Ok, thanks so much again!
sql.lit doesn't work because I get the query with quotes
I used
sql
instead, unless there's a better way.
This is better (type-safety):