mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-07 23:07:00 +02:00
Fix quoting of default values for MariaDB 10 support.
The default values quoting changed in MariaDB 10, and we need to adjust in pgloader: extra '' chars could defeat the default matching logic: "'0000-00-00'" is different from "0000-00-00"
This commit is contained in:
parent
62991bd5c5
commit
460fe6cc77
@ -70,7 +70,7 @@
|
||||
(when default
|
||||
(babel:string-to-octets default)))
|
||||
|
||||
(t default)))
|
||||
(t (ensure-unquoted default #\'))))
|
||||
|
||||
(defun list-all-columns (schema
|
||||
&key
|
||||
|
@ -44,11 +44,15 @@
|
||||
|
||||
(defun quoted-p (s &optional (quote-char #\"))
|
||||
"Return true if s is a double-quoted string"
|
||||
(and (eq (char s 0) quote-char)
|
||||
(eq (char s (- (length s) 1)) quote-char)))
|
||||
(or (null s)
|
||||
(when (< 1 (length s))
|
||||
(and (eq (char s 0) quote-char)
|
||||
(eq (char s (- (length s) 1)) quote-char)))))
|
||||
|
||||
(defun ensure-unquoted (identifier)
|
||||
(cond ((quoted-p identifier)
|
||||
(defun ensure-unquoted (identifier &optional (quote-char #\"))
|
||||
(cond ((null identifier) nil)
|
||||
((< (length identifier) 2) identifier)
|
||||
((quoted-p identifier quote-char)
|
||||
;; when the table name comes from the user (e.g. in the
|
||||
;; load file) then we might have to unquote it: the
|
||||
;; PostgreSQL catalogs does not store object names in
|
||||
|
13
test/mysql/my.sql
vendored
13
test/mysql/my.sql
vendored
@ -1,5 +1,18 @@
|
||||
create table `empty`(id integer auto_increment primary key);
|
||||
|
||||
CREATE TABLE `races` (
|
||||
`raceId` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`year` int(11) NOT NULL DEFAULT 0,
|
||||
`round` int(11) NOT NULL DEFAULT 0,
|
||||
`circuitId` int(11) NOT NULL DEFAULT 0,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`date` date NOT NULL DEFAULT '0000-00-00',
|
||||
`time` time DEFAULT NULL,
|
||||
`url` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`raceId`),
|
||||
UNIQUE KEY `url` (`url`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=989 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `utilisateurs__Yvelines2013-06-28` (
|
||||
`statut` enum('administrateur','odis','pilote','bureau','relais','stagiaire','membre','participant','contact') COLLATE utf8_unicode_ci NOT NULL,
|
||||
`anciennete` year(4) DEFAULT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user