mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-07 23:07:00 +02:00
Fix bugs in the recent extended support for materialized views.
Materialized views without an explicit schema name are supported, but then would raise an error when trying to use destructuring-bind on a string rather than the (cons schema-name table-name). This patch fixes that.
This commit is contained in:
parent
65d323e4a3
commit
b8e8cf7d18
@ -7,7 +7,10 @@
|
|||||||
(in-package #:pgloader.parser)
|
(in-package #:pgloader.parser)
|
||||||
|
|
||||||
(defrule view-name (or qualified-table-name maybe-quoted-namestring)
|
(defrule view-name (or qualified-table-name maybe-quoted-namestring)
|
||||||
(:identity t))
|
(:lambda (vn)
|
||||||
|
(etypecase vn
|
||||||
|
(cons vn)
|
||||||
|
(string (cons nil vn)))))
|
||||||
|
|
||||||
(defrule view-sql (and kw-as dollar-quoted)
|
(defrule view-sql (and kw-as dollar-quoted)
|
||||||
(:destructure (as sql) (declare (ignore as)) sql))
|
(:destructure (as sql) (declare (ignore as)) sql))
|
||||||
|
@ -229,7 +229,7 @@
|
|||||||
(loop :for (name . def) :in views
|
(loop :for (name . def) :in views
|
||||||
:for sql := (destructuring-bind (schema . v-name) name
|
:for sql := (destructuring-bind (schema . v-name) name
|
||||||
(format nil
|
(format nil
|
||||||
"CREATE VIEW ~s.~s AS ~a"
|
"CREATE VIEW ~@[~s~].~s AS ~a"
|
||||||
schema v-name def))
|
schema v-name def))
|
||||||
:do (progn
|
:do (progn
|
||||||
(log-message :info "MS SQL: ~a" sql)
|
(log-message :info "MS SQL: ~a" sql)
|
||||||
@ -249,7 +249,7 @@
|
|||||||
:do (destructuring-bind (name . def) view-definition
|
:do (destructuring-bind (name . def) view-definition
|
||||||
(declare (ignore def))
|
(declare (ignore def))
|
||||||
(format sql
|
(format sql
|
||||||
"~@[, ~]~s.~s"
|
"~@[, ~]~@[~s.~]~s"
|
||||||
(not (zerop i)) (car name) (cdr name)))))))
|
(not (zerop i)) (car name) (cdr name)))))))
|
||||||
(log-message :info "PostgreSQL Source: ~a" sql)
|
(log-message :info "PostgreSQL Source: ~a" sql)
|
||||||
(mssql-query sql))))))
|
(mssql-query sql))))))
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
(loop :for (name . def) :in views
|
(loop :for (name . def) :in views
|
||||||
:for sql := (destructuring-bind (schema . v-name) name
|
:for sql := (destructuring-bind (schema . v-name) name
|
||||||
(format nil
|
(format nil
|
||||||
"CREATE VIEW ~s.~s AS ~a"
|
"CREATE VIEW ~@[~s.~]~s AS ~a"
|
||||||
schema v-name def))
|
schema v-name def))
|
||||||
:do (progn
|
:do (progn
|
||||||
(log-message :info "PostgreSQL Source: ~a" sql)
|
(log-message :info "PostgreSQL Source: ~a" sql)
|
||||||
@ -44,7 +44,7 @@
|
|||||||
:do (destructuring-bind (name . def) view-definition
|
:do (destructuring-bind (name . def) view-definition
|
||||||
(declare (ignore def))
|
(declare (ignore def))
|
||||||
(format sql
|
(format sql
|
||||||
"~@[, ~]~s.~s"
|
"~@[, ~]~@[~s.~]~s"
|
||||||
(not (zerop i)) (car name) (cdr name)))))))
|
(not (zerop i)) (car name) (cdr name)))))))
|
||||||
(log-message :info "PostgreSQL Source: ~a" sql)
|
(log-message :info "PostgreSQL Source: ~a" sql)
|
||||||
(pgsql-execute sql))))))
|
(pgsql-execute sql))))))
|
||||||
|
@ -5,7 +5,7 @@ load database
|
|||||||
-- including only table names matching 'bits', ~/utilisateur/ in schema 'mysql'
|
-- including only table names matching 'bits', ~/utilisateur/ in schema 'mysql'
|
||||||
including only table names matching ~/geolocations/ in schema 'public'
|
including only table names matching ~/geolocations/ in schema 'public'
|
||||||
|
|
||||||
materialize views public.some_usps
|
materialize views some_usps
|
||||||
as $$
|
as $$
|
||||||
select usps, geoid, aland, awater, aland_sqmi, awater_sqmi, location
|
select usps, geoid, aland, awater, aland_sqmi, awater_sqmi, location
|
||||||
from districts
|
from districts
|
||||||
|
Loading…
Reference in New Issue
Block a user