You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
igalklebanov opened this issue
Sep 30, 2024
· 0 comments
· May be fixed by #1175
Labels
apiRelated to library's APIenhancementNew feature or requestmssqlRelated to MS SQL Server (MSSQL)mysqlRelated to MySQLoracleRelated to OraclepostgresRelated to PostgreSQLsqliteRelated to sqlite
Temporal columns with a default value being current date and time are very common.
Forcing users to do:
import{sql}from'kysely'.addColumn('created_at','datetime',(cb)=>cb.defaultTo(sql`CURRENT_TIMESTAMP`))// MySQL / SQLite / PostgreSQL / MSSQL// or.addColumn('created_at','timestampz',(cb)=>cb.defaultTo(sql`now()`))// PostgreSQL
everywhere, is not ideal.
These also come up in issues/discord more often than desired.
There are also other defaultTo use cases that use raw SQL and are quite common.
Worth considering, but not the only way probably:
deprecate defaultTo.
introduce defaultLit for literals (strings, numbers, booleans, etc.).
introduce defaultRaw that accepts any raw SQL string, but has autocompletion for the common stuff like CURRENT_TIMESTAMP, NOW(), gen_random_uuid(), etc. no longer have to import sql template tag. Better DX.
Another approach, given there's not a lot of these:
introduce defaultToCurrentTimestamp().
introduce defaultToNow().
The text was updated successfully, but these errors were encountered:
apiRelated to library's APIenhancementNew feature or requestmssqlRelated to MS SQL Server (MSSQL)mysqlRelated to MySQLoracleRelated to OraclepostgresRelated to PostgreSQLsqliteRelated to sqlite
Hey 👋
Temporal columns with a default value being current date and time are very common.
Forcing users to do:
everywhere, is not ideal.
These also come up in issues/discord more often than desired.
There are also other
defaultTo
use cases that use raw SQL and are quite common.Worth considering, but not the only way probably:
defaultTo
.defaultLit
for literals (strings, numbers, booleans, etc.).defaultRaw
that accepts any raw SQL string, but has autocompletion for the common stuff likeCURRENT_TIMESTAMP
,NOW()
,gen_random_uuid()
, etc. no longer have to importsql
template tag. Better DX.Another approach, given there's not a lot of these:
defaultToCurrentTimestamp()
.defaultToNow()
.The text was updated successfully, but these errors were encountered: