SQLite.swift
SQLite.swift copied to clipboard
Allow expressions as column default values
Hey everyone,
I have a problem with create table. I have tested create a new table with a column that creates automatically DateTime.
CREATE TABLE test (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
t REAL DEFAULT (datetime('now', 'localtime'))
);
insert into test ('name') values ('Lucas')
"1" "Lucas" "2018-08-01 11:07:49"
I've tried to do this way, it doesn't work though.
let exp = Expression<String>("created_at")
tableColumn.column(exp, defaultValue: "(datetime('now', 'localtime'))")
near ""created_at"": syntax error (code: 1)