Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix schema qualified table names usage (more).
When parsing table names in the target URI, we are careful of splitting the table and schema name and store them into a cons in that case. Not all sources methods got the memo, clean that up. See #182 and #186, a pull request I am now going to be able to accept. Also see #287 that should be helped by being able to apply #186.
- Loading branch information
Showing
9 changed files
with
86 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
;;; | ||
;;; Generic API for pgloader sources | ||
;;; | ||
(in-package :pgloader.schema) | ||
|
||
(defmacro push-to-end (item place) | ||
`(setf ,place (nconc ,place (list ,item)))) | ||
|
||
;;; | ||
;;; TODO: stop using anonymous data structures for database catalogs, | ||
;;; currently list of alists of lists... the madness has found its way in | ||
;;; lots of places tho. | ||
;;; | ||
|
||
;;; | ||
;;; A database catalog is a list of schema each containing a list of tables, | ||
;;; each being a list of columns. | ||
;;; | ||
;;; Column structures details depend on the specific source type and are | ||
;;; implemented in each source separately. | ||
;;; | ||
(defstruct schema name tables) | ||
(defstruct table schema name qname columns) | ||
|
||
;;; | ||
;;; Still lacking round tuits here, so for the moment the representation of | ||
;;; a table name is either a string or a cons built from schema and | ||
;;; table-name. | ||
;;; | ||
|
||
(defmacro with-schema ((var table-name) &body body) | ||
"When table-name is a CONS, SET search_path TO its CAR and return its CDR, | ||
otherwise just return the TABLE-NAME. A PostgreSQL connection must be | ||
established when calling this function." | ||
`(let ((,var | ||
(typecase ,table-name | ||
(cons (let ((sql (format nil "SET search_path TO ~a;" | ||
(car ,table-name)))) | ||
(log-message :notice "~a" sql) | ||
(pgloader.pgsql:pgsql-execute sql) | ||
(cdr ,table-name))) | ||
(string ,table-name)))) | ||
,@body)) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters