X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Foodml.lisp;h=e575d4df66ae7e58bc921badebe500629eb55a85;hb=refs%2Fheads%2Fauto-increment;hp=e50905e93436755f53f37bbc49ce9f3bcc06412e;hpb=3c3aa36478f0609e60d83e6c936bf2096fcae726;p=clsql.git diff --git a/sql/oodml.lisp b/sql/oodml.lisp index e50905e..e575d4d 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -232,9 +232,10 @@ :av-pairs av-pairs :database database) (when (and pk-slot (not pk)) - (setf pk (if (member :auto-increment (listify (view-class-slot-db-constraints pk-slot))) + (setf pk (if (or (member :auto-increment (listify (view-class-slot-db-constraints pk-slot))) + (not (null (view-class-slot-autoincrement-sequence pk-slot)))) (setf (slot-value obj (slot-definition-name pk-slot)) - (database-last-autoincrement-id database + (database-last-auto-increment-id database table pk-slot)))) @@ -251,6 +252,14 @@ (slot-definition s)) when (sstoredp sd) collect sd)) + ;; handle slots with defaults + (dolist (slot slots) + (when (and (slot-exists-p slot 'db-constraints) + (listp (view-class-slot-db-constraints slot)) + (member :default (view-class-slot-db-constraints slot))) + (unless (and (slot-boundp obj (slot-definition-name slot)) + (slot-value obj (slot-definition-name slot))) + (update-slot-from-record obj (slot-definition-name slot))))) ;;this may just be a NOP. (setf (slot-value obj 'view-database) database)))