From eaa5807244f179da3c50d48d98dc72ab826e3f5f Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Wed, 24 Feb 2016 18:30:16 +0100 Subject: [PATCH] Adapt to CURRENT_TIMESTAMP(x) default values. We target CURRENT_TIMESTAMP as the PostgreSQL default value for columns when it was different before on the grounds that the type casting in PostgreSQL is doing the job, as in the following example: pgloader# create table test_ts(ts timestamptz(6) not null default CURRENT_TIMESTAMP); CREATE TABLE pgloader# insert into test_ts VALUES(DEFAULT); INSERT 0 1 pgloader# table test_ts; ts ------------------------------- 2016-02-24 18:32:22.820477+01 (1 row) pgloader# drop table test_ts; DROP TABLE pgloader# create table test_ts(ts timestamptz(0) not null default CURRENT_TIMESTAMP); CREATE TABLE pgloader# insert into test_ts VALUES(DEFAULT); INSERT 0 1 pgloader# table test_ts; ts ------------------------ 2016-02-24 18:32:44+01 (1 row) Fix #341. --- src/utils/pg-format-column.lisp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/pg-format-column.lisp b/src/utils/pg-format-column.lisp index ad371b9..f215d75 100644 --- a/src/utils/pg-format-column.lisp +++ b/src/utils/pg-format-column.lisp @@ -9,8 +9,10 @@ (cond ((null default) "NULL") ((and (stringp default) (string= "NULL" default)) default) - ((and (stringp default) (string= "CURRENT_TIMESTAMP" default)) default) - ((and (stringp default) (string= "CURRENT TIMESTAMP" default)) + ((and (stringp default) + ;; address CURRENT_TIMESTAMP(6) and other spellings + (or (uiop:string-prefix-p "CURRENT_TIMESTAMP" default) + (string= "CURRENT TIMESTAMP" default))) "CURRENT_TIMESTAMP") ((and (stringp default) (string= "newsequentialid()" default)) "uuid_generate_v1()")