+7 Jul 2004 Kevin Rosenberg <kevin@rosenberg.net>
+ * 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 <m.t.pearce@city.ac.uk>
* sql/expressions.lisp: add AUTO-INCREMENT and UNIQUE to the
recognised column constraints for CREATE-TABLE and the :DB-CONSTRAINTS
(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))
(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")))
(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)))
(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."
(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
#:bigint
#:varchar
#:generalized-boolean
+ #:smallint
#:*default-string-length*
;; OODML (oodml.lisp)