issue with complied sql when doing + interval operation
Hey,
I have a query that is generated using kysely where I select the following field sql that I get as a string from a file:
fields = [close_date + interval '12 month']
what happens is that when I do .select(fields)
the close_date + interval '12 month' gets wrapped in double quotes, what is the best way to correct this
14 Replies
Could you provide the query using https://kyse.link?
https://kyse.link/?p=s&i=soeyDA0b9jYm2BGAvx4U
hope that makes sense
Something like this https://kyse.link/?p=s&i=uVGAzQkXhjYo5lBc0S5s
ok but I have a list of sql queries and I want to add them to the select clause and give each a different alias
That's going to be very difficult to do in a type-safe way
You can of course drop down to
Kysely<any>
and write whatever query you want, but the output type will not be automatically inferredok then what should I do ?
Switch to drizzle?
drizzle ? please explain
@koskimas
You can do something like this https://kyse.link/?p=s&i=767sswpj75AFEMo2DaZf, but I'm guessing this is not the whole query you want to build. You probably need to use
Kysely<any>
for this.
And actually the types are completely wrong in my example. For dynamic set of selections with dynamic aliases, you just need to forget type-safety and manually type the result.I will try the thing you suggested in the link
after my meeting 🙂
So you were on a meeting but insisted that I help you immediately. Wow dude. I think I'm done
I just when into the metting 6 minutes ago man, sorry for that
I tagged you on xx:13
my meeting was at xx:15
this didn't work, getting the same format as it had at the beginning with the double quotes
@koskimas I used your solution with cobination of the following:
this worked