From d528dfe7e23fe5732fdbf1a282498fbec298d6cd Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 7 Jul 2004 18:03:23 +0000 Subject: [PATCH] r9739: 7 Jul 2004 Kevin Rosenberg * sql/ooddl.lisp: Added SMALLINT type * sql/generic-postgresql.lisp: Added INT2 as SMALLINT type * db-mysql/mysql-objects.lisp: Added SMALLINT type * sql/package.lisp: Export SMALLINT * sql/expressions.lisp: Add MYSQL's UNSIGNED and ZEROFILL as db-constraints --- ChangeLog | 8 ++++++++ db-mysql/mysql-objects.lisp | 5 +++++ sql/expressions.lisp | 2 ++ sql/generic-postgresql.lisp | 7 ++++++- sql/oodml.lisp | 18 +++++++++++++++++- sql/package.lisp | 1 + 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59866b9..6bdb6fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +7 Jul 2004 Kevin Rosenberg + * sql/ooddl.lisp: Added SMALLINT type + * sql/generic-postgresql.lisp: Added INT2 as SMALLINT type + * db-mysql/mysql-objects.lisp: Added SMALLINT type + * sql/package.lisp: Export SMALLINT + * sql/expressions.lisp: Add MYSQL's UNSIGNED and ZEROFILL as + db-constraints + 6 Jul 2004 Marcus Pearce * sql/expressions.lisp: add AUTO-INCREMENT and UNIQUE to the recognised column constraints for CREATE-TABLE and the :DB-CONSTRAINTS diff --git a/db-mysql/mysql-objects.lisp b/db-mysql/mysql-objects.lisp index 29013c7..5ddad8b 100644 --- a/db-mysql/mysql-objects.lisp +++ b/db-mysql/mysql-objects.lisp @@ -20,6 +20,11 @@ (declare (ignore args database)) "DATETIME") +(defmethod database-get-type-specifier ((type (eql 'smallint)) args database + (db-type (eql :mysql))) + (declare (ignore args database)) + "SMALLINT") + (defmethod database-output-sql-as-type ((type (eql 'boolean)) val database (db-type (eql :mysql))) (declare (ignore database)) diff --git a/sql/expressions.lisp b/sql/expressions.lisp index ace3603..2a0085f 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -842,6 +842,8 @@ uninclusive, and the args from that keyword to the end." (cons (symbol-name-default-case "NULL") "NULL") (cons (symbol-name-default-case "PRIMARY") "PRIMARY") (cons (symbol-name-default-case "KEY") "KEY") + (cons (symbol-name-default-case "UNSIGNED") "UNSIGNED") + (cons (symbol-name-default-case "ZEROFILL") "ZEROFILL") (cons (symbol-name-default-case "AUTO-INCREMENT") "AUTO_INCREMENT") (cons (symbol-name-default-case "UNIQUE") "UNIQUE"))) diff --git a/sql/generic-postgresql.lisp b/sql/generic-postgresql.lisp index cf3fac3..43a9201 100644 --- a/sql/generic-postgresql.lisp +++ b/sql/generic-postgresql.lisp @@ -32,7 +32,12 @@ (declare (ignore database)) (if args (format nil "CHAR(~A)" (car args)) - "VARCHAR")) + "VARCHAR")) + +(defmethod database-get-type-specifier ((type (eql 'smallint)) args database + (db-type (eql :postgresql))) + (declare (ignore args database)) + "INT2") (defmethod database-get-type-specifier ((type (eql 'wall-time)) args database (db-type (eql :postgresql))) diff --git a/sql/oodml.lisp b/sql/oodml.lisp index d701f09..499a4ed 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -315,7 +315,15 @@ (declare (ignore database db-type)) (if args (format nil "INT(~A)" (car args)) - "INT")) + "INT")) + +(deftype smallint () + "An integer smaller than a 32-bit integer, this width may vary by SQL implementation." + 'integer) + +(defmethod database-get-type-specifier ((type (eql 'smallint)) args database db-type) + (declare (ignore args database db-type)) + "INT") (deftype bigint () "An integer larger than a 32-bit integer, this width may vary by SQL implementation." @@ -499,6 +507,14 @@ (parse-integer val))) (number val))) +(defmethod read-sql-value (val (type (eql 'smallint)) database db-type) + (declare (ignore database db-type)) + (etypecase val + (string + (unless (string-equal "NIL" val) + (parse-integer val))) + (number val))) + (defmethod read-sql-value (val (type (eql 'bigint)) database db-type) (declare (ignore database db-type)) (etypecase val diff --git a/sql/package.lisp b/sql/package.lisp index 011353b..8d5c33d 100644 --- a/sql/package.lisp +++ b/sql/package.lisp @@ -348,6 +348,7 @@ #:bigint #:varchar #:generalized-boolean + #:smallint #:*default-string-length* ;; OODML (oodml.lisp) -- 2.34.1