SQLite.swift icon indicating copy to clipboard operation
SQLite.swift copied to clipboard

Allow expressions as column default values

Open lucascorrea opened this issue 7 years ago • 0 comments

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)

lucascorrea avatar Aug 01 '18 10:08 lucascorrea