Using Postgres function in an insert with a field as a select
create role in migration
How to insert JSONB types in postgres?
Record
type? What if the field is optional?...Querying two different tables with subset of common columns
.where
s) that I'd like to apply for both queries, and it's quite extensive so I'd prefer not to copy and paste. My query would only .select
the common columns.
Is there any Kysely-ic way of doing this?...How to select from a function with parameters?
kysely
will not natively support stored procedures / functions, and was wondering if there's a pattern for this:
select * from function_name(<parameters>)
select * from function_name(<parameters>)
In a transaction, how do you ignore generated field requirements?
document
Cross database joins in MySQL
.where('x', 'is not', null) and correspond type's nullability
string | null
. Is it possible to write a query that ends up resulting in a final type of string
after using .where('x', 'is not', null)
or any similar method?.$narrowType
that allows you to narrow the output type safely....What is the suggested way of adding/removing methods to expression builders?
Running database agnostic queries (MySQL)
DROP DATABASE a
or CREATE DATABASE a
?
Other similar use cases include:
RESET QUERY CACHE
, SELECT 1
(for latency check), etc...Asserting type of .countAll() (MySQL)
countAll()
and sum()
are string | number | bigint
.
I assume this is in-case the number returned is too large to be stored in a JS "number." In my case, it appears to be being returned as strings
. Is it possible to assert it as a number
so that I don't need to wrap every query in a parseInt(result as string, 10)
?...Coalesce return empty array
null
when an array column is empty?
I already tried
``ts
.select(coalesce("categories",sql
ARRAY[]::"CollectionCategory"[]`).as("categories"))...kysely-codegen for multiple databases
--out-file
, rename the exported interfaces, then manually update index.d.ts
, but I was wondering if there's a better solution?...Using MySQL functions in SELECT statement
selectRaw
for these
SELECT a, b, UPPER(c) FROM x;
...Extract OrderBy TS Keys
insert into with mix of static and table values
INSERT INTO some_table (a, b, c, d) SELECT o.a, o.b, 16, 'hello world' FROM other_table O WHERE somekey = 32;
INSERT INTO some_table (a, b, c, d) SELECT o.a, o.b, 16, 'hello world' FROM other_table O WHERE somekey = 32;
Migration error "TypeError: Cannot read properties of undefined (reading 'getExecutor')"
where clause with length
select * from data where length(prodcode) = 3
...show generated sql
Property does not exist on type