Question about ColumnTypes and dates.
DATE
(yyyy-mm-dd).
```sql
CREATE TABLE IF NOT EXISTS person(
id INT NOT NULL,...ColumnType
which would be used in where
statements (and other similar statements).
But then subqueries in where
statements would break if the select type and the query type don't match....How to type tables with dynamic names?
.withTables
and in the queries, and implement a plugin that on-the-fly adds the random suffix to all references to that table....clone select query
Any limits on insertValues(array)?
Migration to seed huge amount of data
Creating a jsonAgg helper funtcion that returns a context aware `AggregateFunctionBuilder`
eb.fn.jsonAgg
does but for JSONB.
- I have tried using the helpers/postgres/jsonArrayFrom
, but that is functionally not the same because it creates a subquery.
- I have tried creating a simple helper, but it's not type/context aware, and it doesn't support method chaining (.distinct()
for example):
...How to add array column in migrations?
.addColumn('countyNames', sql`varchar[]`)
.addColumn('countyNames', sql`varchar[]`)
are conditional CTEs possible?
Type 'QueryCreatorWithCommonTableExpression ... The types returned by 'with(...)' are incompatible between these types.
...Dynamic conditional raw query question
``ts
await sql
SELECT
column AS "data"
FROM my_table ...Update on conflict clause
SelectAll Overwrites column with same field name in a join
concat in postgres
||
to concat. What am I doing wrong?
```
let warehouses = await db
.selectFrom('warehouse as w')...Type-only imports in migration files
Kysely
from the kysely
package. This import is only used to type the up
and down
functions, but not as a value. Depending on the TypeScript verbatimModuleSyntax
compiler option, this may or may not result in a runtime import in the compiled code, which in the worst case could mean different behaviors of the migration script.
My question is: Is it safe to import Kysely
with a type-only import in migration files? If not, what side effects of the import are needed in such files?
If the idea (as I suspect) is indeed only to import the Kysely
type for typing the function arguments, I suggest also that the example should be changed to use a type-only import or accompanied by a note about the possibility of such an import....Typing reusable functions for filtering rows
generating raw sql?
.compile()
method instead of executing.
For more info, check out the link @53ny posted....Conditionally updating fields
UPDATE table SET field = IF(condition, trueValue, falseValue) WHERE someCondition;
, i can't exactly seem to find that in the docs
Driver used: MySQL...How to cast to date. eg : `DATE(created_at)`
transaction takes too long
Syntax error when empty array is passed to a WHERE filter (request for more readable errors)
someQuery.where("x", "in", xs)
, if xs
is empty, then the error will be something like error: syntax error at or near ")"
. Given that in complex queries there can be multiple places that could cause such an issue, debugging it is sometimes painful.
I understand that it's SQL that is throwing the error and empty arrays are not possible, but would it be feasible to do a runtime check by the lib and throw a more readable error in case that happens? Or would this be against the philsophy of Kysely or too much overhead?
Also, I think a fallback of 1=0
might make even more sense, since that should be the logical output of the query with an empty array....Derived tables for Postgres