Tim Lonsdale
Tim Lonsdale
KKysely
Created by Tim Lonsdale on 4/17/2025 in #help
Can't figure out how to add a unique index on (foo, LOWER(bar)) for a table
Sorry chaps if this is obvious but can't seem to see any mention of this in the docs. I need to create a unique index on a tuple of columns - with the caveat that the second column is "case insensitive" - i achieve this by lowercasing the second column. I believe this is quite normal to do in vanilla pg but am unsure what the idiomatic way to do this in kysely is...
9 replies
KKysely
Created by Tim Lonsdale on 2/11/2025 in #help
Getting the underlying connection pool/client from a kysely wrapper
Hi guys, I have a migration script that takes a raw PgClient object. Was wondering if it would be possible to extract said object from the Kysely<any> that is passed into the migration functions (up down) thanks!
4 replies
KKysely
Created by Tim Lonsdale on 1/27/2025 in #help
Is it okay to repeatedly wrap a PG connection pool with kysely?
Chaps, my understanding is that it is safe to repeatedly wrap a postgres connection pool with kysely a la "new Kysely<DB>({dialect: new PostgresDialect({ pool }) })", and I can just let those kysely wrappers get garbage collected. Is this correct?
5 replies
KKysely
Created by Tim Lonsdale on 1/17/2025 in #help
Overcoming issue with `withSchema` and `forUpdate`
Hi chaps, I just posted a github issue: https://github.com/kysely-org/kysely/issues/1324 w.r.t. Kysely using qualified table names in the forUpdate if withSchema is used. Postgres doesn't like this and will error - I wonder if there is anything I can do short-term/now to skirt this issue that doesn't cause the typechecker to complain? Thanks!
5 replies
KKysely
Created by Tim Lonsdale on 1/13/2025 in #help
2-Way transforming of types
My front-end wants UUIDs in a shortened format (i.e. base-64'd encode of the uuid bytes). In order to minimize workload, I was hoping I could write some sort of transformer that I could plug into kysely that would inflate shortened UUIDs when going into the DB and deflate them to the shortened format when they go out. I can't see anything obvious that would serve me to this end. Any suggestions?
3 replies
KKysely
Created by Tim Lonsdale on 12/19/2024 in #help
Is there a way to execute parameterized SQL (with paremeters) within a kysely migration?
I have a third party library that requires I make some changes to the database. I want to run this as part of my other kysely migrations. This library gives me an array of [sql : string, parameters : unknown[]]. Any idea how best I should run these as part of a kysely migration?
2 replies
KKysely
Created by Tim Lonsdale on 12/7/2024 in #help
Unioning an array of sql`{SQL_QUERY}`
Hey chaps, I'm doing some really heinous shit with triggers etc (hence why I'm not using Kysely's default query builder syntax). I have an array of SQL queries that I'd like to UNION ALL together - any idea how best to do that? Note - the length of the query array is dynamic - Thanks!!
5 replies