Autoincrement support for Sqlite3
Victor <[email protected]> Fri, 27 Sep 2013 19:42:52 +0300
| Newsgroups | gmane.lisp.clsql.general |
|---|---|
| Message-ID | <op.w32vs62j4lizsz@vanyakin-nb> |
Hi, Thanks a lot for creating such a wonderful and useful library. However, lack of autoincrement fields support for Sqlite3 databases is very inconvenient. I wanted to share a patch (partially it was submitted before) that makes it possible to work with autoincrement fields in Sqlite3 with clsql. Additional modifications might be necessary, but this patch at least makes it possible to insert objects into the database. I hope that CLSQL will have a full support for autoincrement fields in the Sqlite3 databases. Thanks, Victor _______________________________________________ CLSQL mailing list [email protected] http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
file.patch
(application/octet-stream, 1.3 KB)
diff --git a/db-sqlite3/sqlite3-sql.lisp b/db-sqlite3/sqlite3-sql.lisp
index 63e48ec..d645c33 100644
--- a/db-sqlite3/sqlite3-sql.lisp
+++ b/db-sqlite3/sqlite3-sql.lisp
@@ -320,6 +320,14 @@
(or (string-equal ":memory:" name)
(and (probe-file name) t))))
+(defmethod database-get-type-specifier ((type (eql 'integer))
+ args database
+ (db-type (eql :sqlite3)))
+ (declare (ignore database))
+ (if args
+ (format nil "INTEGER(~A)" (car args))
+ "INTEGER"))
+
;;; Database capabilities
(defmethod db-type-has-boolean-where? ((db-type (eql :sqlite3)))
diff --git a/sql/expressions.lisp b/sql/expressions.lisp
index 8b6167b..0e4d71f 100644
--- a/sql/expressions.lisp
+++ b/sql/expressions.lisp
@@ -1105,6 +1105,7 @@ uninclusive, and the args from that keyword to the end."
(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 "AUTOINCREMENT") "AUTOINCREMENT") ;; for sqlite3 support
(cons (symbol-name-default-case "DEFAULT") "DEFAULT")
(cons (symbol-name-default-case "UNIQUE") "UNIQUE")
(cons (symbol-name-default-case "IDENTITY") "IDENTITY (1,1)") ;; added for sql-server support