From 33fc3add2546eed73fa2087fc548b88538a23705 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Fri, 4 Sep 2015 12:25:11 +0200 Subject: [PATCH] Handle default values particularities for IXF. It turns out that IXF format might embed particulars of the systems the data comes from (Informix or DB2) and we need to process some strings so that they are compatible with PostgreSQL ("CURRENT TIMESTAMP" here). See #272 that should be fixed here, but being in the blind, don't close the issue just yet. --- src/sources/ixf/ixf-schema.lisp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sources/ixf/ixf-schema.lisp b/src/sources/ixf/ixf-schema.lisp index 30c2052..946bce5 100644 --- a/src/sources/ixf/ixf-schema.lisp +++ b/src/sources/ixf/ixf-schema.lisp @@ -47,6 +47,11 @@ (error "IXF Type mapping unknown for: ~x" ixf-type)) pgtype)) +(defun format-default-value (default) + "IXF has some default values that we want to transform here, statically." + (cond ((string= "CURRENT TIMESTAMP" default) "CURRENT_TIMESTAMP") + (t default))) + (defmethod format-pgsql-column ((col ixf:ixf-column)) "Return a string reprensenting the PostgreSQL column definition" (let* ((column-name (apply-identifier-case (ixf:ixf-column-name col))) @@ -56,7 +61,7 @@ (cast-ixf-type (ixf:ixf-column-type col)) (ixf:ixf-column-nullable col) (ixf:ixf-column-has-default col) - (ixf:ixf-column-default col)))) + (format-default-value (ixf:ixf-column-default col))))) (format nil "~a ~22t ~a" column-name type-definition)))