K
Kysely14mo ago
Luccas

jsonb_build_object and raw sql possibilities

is possible to do this query without use sql.raw?
sql<string>`jsonb_build_object(${sql.join([
sql.raw(`'hair_type',coalesce (dog.hair_type, dog_breed.hair_type)`),
sql.raw(`'ear_type',coalesce (dog.ear_type, dog_breed.ear_type)`),
sql.raw(`'size',coalesce (dog.size, dog_breed.size)`),
])})`
sql<string>`jsonb_build_object(${sql.join([
sql.raw(`'hair_type',coalesce (dog.hair_type, dog_breed.hair_type)`),
sql.raw(`'ear_type',coalesce (dog.ear_type, dog_breed.ear_type)`),
sql.raw(`'size',coalesce (dog.size, dog_breed.size)`),
])})`
2 Replies
Luccas
LuccasOP14mo ago
too elegant, tks
Want results from more Discord servers?
Add your server