thelinuxlich
thelinuxlich
Explore posts from servers
KKysely
Created by thelinuxlich on 9/20/2024 in #help
eb.fn.coalesce on a subquery
Is it possible somehow?
6 replies
KKysely
Created by thelinuxlich on 12/14/2023 in #help
CASE with subquery clause
How can I return the column value from the subquery in a CASE? With this example, Kysely thinks the second condition is { name: string }:
eb.case()
.when('re.type', '=', 'company')
.then(eb.ref('cd.name'))
.else(
eb
.selectFrom('rise.companies_data as cd')
.select(['cd.name'])
.where(
'cd.riseid',
'=',
eb.selectFrom('rise.rise_entities as re2')
.select(['re2.parent_riseid'])
.where('re2.type', '=', 'team')
.whereRef('re2.riseid', '=', 're.riseid'),
),
)
.end()
.as('company_name')
eb.case()
.when('re.type', '=', 'company')
.then(eb.ref('cd.name'))
.else(
eb
.selectFrom('rise.companies_data as cd')
.select(['cd.name'])
.where(
'cd.riseid',
'=',
eb.selectFrom('rise.rise_entities as re2')
.select(['re2.parent_riseid'])
.where('re2.type', '=', 'team')
.whereRef('re2.riseid', '=', 're.riseid'),
),
)
.end()
.as('company_name')
13 replies
KKysely
Created by thelinuxlich on 10/19/2023 in #help
How do I create a helper to be used on a select array of fields?
I want to create a toBool helper to convert from tinyint, however I'm lost on the type I need to pass to get autocomplete of the possible fields in the select
import { sql } from 'kysely'

export const toBool = (
field: string // what type should I add here?
) => {
return sql<boolean>`IF(${field} > 0, true, false)`
}
import { sql } from 'kysely'

export const toBool = (
field: string // what type should I add here?
) => {
return sql<boolean>`IF(${field} > 0, true, false)`
}
5 replies
KKysely
Created by thelinuxlich on 10/17/2023 in #help
How do I cast the type of a eb.fn('...') ?
I tried with eb.fn<string>("CONCAT", [....]) but it didn't worked
9 replies
KKysely
Created by thelinuxlich on 10/11/2023 in #help
Insert values from subquery
5 replies
KKysely
Created by thelinuxlich on 10/3/2023 in #help
Binary fields in mySQL
I have a schema with ids stored as BINARY (sucks I know). Is it possible to write a plugin to convert them to string when receiving?
8 replies
KKysely
Created by thelinuxlich on 3/6/2023 in #help
Weird importing error on latest Kysely 0.23.5
2 replies