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
Complex Query Builder from dynamic input - Typescript issue
conditionBuilder
might return undefined
and .where
expects something....How to add table/column comments when creating tables?
modifyEnd
where possible to add comments with sql
template tag....Need help improving a custom helper
ExpressionBuilder
callback thingy anywhere if it did. We could just use free functions and they'd somehow catch the context through generics in the return value.
another option is month(eb)('created_at')
....jsonArrayFrom with `as` not being typed
How to use multiple schema definitions ( e.g. <catalog>.<schema>.<table> )
Using raw SQL with `or` where
orWhere
clause using it. Here is a simple example of what I am trying to achieve.
```ts
const result = await db
.selectFrom('users')...eb.or
expects a list of Expression<SqlBool>
where SqlBool
is boolean | 0 | 1