Commit 4e0e0722 authored by Ryszard Szopa's avatar Ryszard Szopa
Browse files

Bugfix: unique constraints for single slots.

darcs-hash:83fc346a06be6a9f70ff9601368dbdb09e73f44d
parent 16f91c22
...@@ -104,7 +104,7 @@ be reverted.)" ...@@ -104,7 +104,7 @@ be reverted.)"
(otherwise (on-delete slot))))) (otherwise (on-delete slot)))))
(defmethod add-constraint ((slot db-class-slot-definition) (constraint (eql :unique))) (defmethod add-constraint ((slot db-class-slot-definition) (constraint (eql :unique)))
(format nil "UNIQUE ~A" (format nil "UNIQUE \(~A\)"
(sql-ize (slot-definition-name slot)))) (sql-ize (slot-definition-name slot))))
(defmethod add-constraint ((list list) (constraint (eql :unique))) (defmethod add-constraint ((list list) (constraint (eql :unique)))
......
...@@ -300,11 +300,16 @@ metaclass set to HTML and the right connection-spec." ...@@ -300,11 +300,16 @@ metaclass set to HTML and the right connection-spec."
((foo :type integer :accessor foo :initarg :foo) ((foo :type integer :accessor foo :initarg :foo)
(bar :type integer :accessor bar :initarg :bar )) (bar :type integer :accessor bar :initarg :bar ))
(:unique (foo bar)))) (:unique (foo bar))))
(finishes (defdao-example seis ()
((foo :type integer :accessor foo :initarg :foo :unique t))))
(make-and-save 'cinco :foo 1 :bar 1) (make-and-save 'cinco :foo 1 :bar 1)
(finishes (make-and-save 'cinco :foo 1 :bar 2)) (finishes (make-and-save 'cinco :foo 1 :bar 2))
(finishes (make-and-save 'cinco :foo 2 :bar 1)) (finishes (make-and-save 'cinco :foo 2 :bar 1))
(signals cl-postgres:database-error (make-and-save 'cinco :foo 1 :bar 1))) (signals cl-postgres:database-error (make-and-save 'cinco :foo 1 :bar 1))
(make-and-save 'seis :foo 1)
(signals cl-postgres:database-error (make-and-save 'seis :foo 1)))
;;; Copyright (C) 2007 ;;; Copyright (C) 2007
;;; Ryszard Szopa <ryszard.szopa@gmail.com> & ;;; Ryszard Szopa <ryszard.szopa@gmail.com> &
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment