diff --git a/src/sources.lisp b/src/sources.lisp index d6b19e7..04e23c4 100644 --- a/src/sources.lisp +++ b/src/sources.lisp @@ -431,8 +431,8 @@ "Returns suitably quoted default value for CREATE TABLE command." (cond ((null default) "NULL") - ((string= "NULL" default) default) - ((string= "CURRENT_TIMESTAMP" default) default) + ((and (stringp default) (string= "NULL" default)) default) + ((and (stringp default) (string= "CURRENT_TIMESTAMP" default)) default) (t ;; apply the transformation function to the default value (if using-cast-fn (format-pgsql-default-value diff --git a/src/sources/mysql/mysql-schema.lisp b/src/sources/mysql/mysql-schema.lisp index 05a556b..2ad1779 100644 --- a/src/sources/mysql/mysql-schema.lisp +++ b/src/sources/mysql/mysql-schema.lisp @@ -159,6 +159,15 @@ order by table_name" dbname only-tables)))) (cons (format nil "~:[~;NOT ~]REGEXP '~a'" not (cadr filter))))) filter-list)) +(defun cleanup-default-value (dtype default) + "MySQL catalog query always returns the default value as a string, but in + the case of a binary data type we actually want a byte vector." + (cond ((string= "binary" dtype) + (when default + (babel:string-to-octets default))) + + (t default))) + (defun list-all-columns (&key (dbname *my-dbname*) (table-type :table) @@ -192,10 +201,10 @@ order by table_name, ordinal_position" excluding ; do we print the clause? (filter-list-to-where-clause excluding t))) do - (let ((entry (assoc table-name schema :test 'equal)) - (column - (make-mysql-column - table-name name dtype ctype default nullable extra))) + (let* ((entry (assoc table-name schema :test 'equal)) + (def-val (cleanup-default-value dtype default)) + (column (make-mysql-column + table-name name dtype ctype def-val nullable extra))) (if entry (push column (cdr entry)) (push (cons table-name (list column)) schema)))