-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I've tried to use auto-increment slots on the sqlite3 backend, and they seem to be working only partially. The following code is not working:
(ql:quickload "clsql")`
(ql:quickload "clsql-sqlite3")
(clsql:def-view-class foo ()
((id :accessor id :initarg :id :type integer
:db-constraints (:not-null :auto-increment))))
(defun test ()
(clsql:with-database (clsql:*default-database* '("foo.sqlite3") :database-type :sqlite3)
(let ((clsql:*db-auto-sync* t))
(ignore-errors
(clsql:create-view-from-class 'foo))
(let ((x (make-instance 'foo)))
;; this will fail -- error: The slot CL-USER::ID is unbound in the object #<FOO {100BF60C03}>.
(id x)))))
(test)
=> error: The slot CL-USER::ID is unbound in the object #<FOO {100BF60C03}>It seems that the issue has been mentioned on the mailing list in 2010 http://article.gmane.org/gmane.lisp.clsql.general/1221 and traces of the patch suggested back then (before code refactoring) seem to be around, yet behavior is wrong.
I'm struggling to suggest an appropriate fix. My analysis is that update-autoincrement-keys is not called, since %update-instance-helper decides the slot is not one that needs updating. That is a decision apparently made at view-class construction time. I can't currently test against a different backend to see whether (and why) it works there.
Any hints? I'm ready to try and fix it with some guidance.
(for the record: this is on OSx, sbcl 1.3.3, quicklisp's march release, which contains clsql from kpe.io master branch in january 2016 AFAICS)
uuh