From 355aedfd72558516a58cc70cde205a5034321747 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 8 Jun 2017 21:39:06 +0200 Subject: [PATCH] Fix "drop default" casting rule. The previous coding would discard any work done at the apply-casting-rules step when adding source specific smarts about handling default, because of what looks like negligence and bad tests. A test case scenario exists but was not exercized :( Fix that by defaulting the default value to the one given back at the apply-casting-rules stage, where we apply the "drop default" clause. --- src/sources/mssql/mssql-cast-rules.lisp | 2 +- src/sources/mysql/mysql-cast-rules.lisp | 2 +- src/sources/sqlite/sqlite-cast-rules.lisp | 2 +- test/sqlite.load | 13 ++++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sources/mssql/mssql-cast-rules.lisp b/src/sources/mssql/mssql-cast-rules.lisp index 52197ce..b2c8ce6 100644 --- a/src/sources/mssql/mssql-cast-rules.lisp +++ b/src/sources/mssql/mssql-cast-rules.lisp @@ -147,6 +147,6 @@ (string= "newsequentialid()" default))) :generate-uuid) - (t default))) + (t (column-default pgcol)))) pgcol))) diff --git a/src/sources/mysql/mysql-cast-rules.lisp b/src/sources/mysql/mysql-cast-rules.lisp index 00c9bd2..a2ec843 100644 --- a/src/sources/mysql/mysql-cast-rules.lisp +++ b/src/sources/mysql/mysql-cast-rules.lisp @@ -175,7 +175,7 @@ (or (uiop:string-prefix-p "CURRENT_TIMESTAMP" default) (string= "CURRENT TIMESTAMP" default))) :current-timestamp) - (t default))) + (t (column-default pgcol)))) ;; extra user-defined data types (when (or (string-equal "set" dtype) diff --git a/src/sources/sqlite/sqlite-cast-rules.lisp b/src/sources/sqlite/sqlite-cast-rules.lisp index d1fdb23..34f7dc2 100644 --- a/src/sources/sqlite/sqlite-cast-rules.lisp +++ b/src/sources/sqlite/sqlite-cast-rules.lisp @@ -100,7 +100,7 @@ (or (uiop:string-prefix-p "CURRENT_TIMESTAMP" default) (string= "CURRENT TIMESTAMP" default))) :current-timestamp) - (t default))) + (t (column-default pgcol)))) pgcol))) diff --git a/test/sqlite.load b/test/sqlite.load index 2a9ffc0..2de3075 100644 --- a/test/sqlite.load +++ b/test/sqlite.load @@ -4,16 +4,15 @@ load database -- with include drop, create tables, create indexes, reset sequences - -- excluding table names like 'appointments' - before load do $$ drop schema if exists sqlite cascade; $$, $$ create schema if not exists sqlite; $$ cast column character.f1 to text drop typemod, - column appointments.time - to timestamptz drop default - using sqlite-timestamp-to-timestamp, - type intege to integer + column appointments.time to timestamptz drop default, + type intege to integer, + type character to varchar keep typemod - set work_mem to '16MB', maintenance_work_mem to '512 MB', search_path to 'sqlite'; \ No newline at end of file + set work_mem to '16MB', + maintenance_work_mem to '512 MB', + search_path to 'sqlite';