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.
This commit is contained in:
Dimitri Fontaine 2017-06-08 21:39:06 +02:00
parent d74c9625a3
commit 355aedfd72
4 changed files with 9 additions and 10 deletions

View File

@ -147,6 +147,6 @@
(string= "newsequentialid()" default)))
:generate-uuid)
(t default)))
(t (column-default pgcol))))
pgcol)))

View File

@ -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)

View File

@ -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)))

View File

@ -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';
set work_mem to '16MB',
maintenance_work_mem to '512 MB',
search_path to 'sqlite';