Reusable CTEs that depend on previous CTEs
eligibleChats
instead of chatMessages
, then you can do it like this
QueryCreator<DB & { eligibleChats: { chatId: string } }>
QueryCreator<DB & { eligibleChats: { chatId: string } }>
`update set from`
update set from
sql syntax. So far, I've been unable to figure out how (in lieu of dropping down to raw sql).
We are planning to craft many of our update statements as batch operations in our repository layer, so this pattern will be used heavily.
Here's some example sql to make it clear (hopefully) what I'm trying to do...Are JSON Arrays not supported for paramterization in the postgres driver?
string
, everything works correctly. The row type is inferred correctly for output data.
https://kyse.link/?p=s&i=NBfnbfzwNBlZ0YJpc7dj...Combining selectAll and arbitrary expressions
selectAll
(for selecting all columns of a couple of tables) and then add a couple of expressions like jsonArrayFrom
on top of that?select
and selectAll
as many times as you want. The calls are additiveHow to plugin column aliases with table prefix?
.selectAll('t1', 'prefix_t1')
.selectAll('t1', 'prefix_t1')
Query building optimization question
eb
. If I have a conditional select query, is this efficiently using the eb
object for my query? Is it ok to use multiple levels of eb
s ?
```ts
// some input
args = {
param: ['foo', 'bar']...Why is eb inferred as any in this update query?
eb
variable in its expression builder. If I change the where clause to an eb callback, it does properly infer the type, which makes me concerned I'm not doing this correctly.
Am I doing something wrong? Is this a minor typing bug?
Here's the code example:...Zero number omitted from parameters
Is there any way to postgres notify and listen with kysley?
pg.on
but I would create a new instance connection just for that. It would be much better if I can use kysley for pg_notify listener? Could I build a plugin with the current plugin systems? is it possible? or I can already use raw sql query?bool_or
How to retrieve field name raising error in database?
Using sql.lit
Any thoughts on how to move data migrations from knex to kysely?
Using a custom HTTP driver for Kysely
kysely-planetscale
), or do I need to make the driver myself?How to order by with embeddings using pgvector?
Recipe for generated types + JSON?
Consensus on immutable vs. mutable result for .executeTakeFirst
executeTakeFirst
should be immutable? Or is this up to the dialect/not a concern of Kysely?
I'm asking because I seem to have found an inconsistency with kysely-libsql where the result of executeTakeFirst
is immutable, but this isn't the case for built-in dialects (checked Sqlite and Pg). ...CamelCasePlugin
, Kysely doesn't touch the result in any way. It just returns what the driver returns.Relational table join question
user
and account
joined via the user_account
relational tables, if I use jsonArrayFrom
from a query on the user
table to get accounts, do I always need to do a join with the intermediary table or does Kysely provide any type of shortcut for this?Raw SQL in select type to number
sql<number>`(${sql.raw(precisionScore)} * 100)::NUMERIC(10,2)`
sql<number>`(${sql.raw(precisionScore)} * 100)::NUMERIC(10,2)`
pg
driver returns numeric type as a string. Use the pg-types
package to configure the type.