Commit aa888af9 authored by ryszard.szopa's avatar ryszard.szopa
Browse files

bugfix: add-constraint/relate.

No call to SQL-IZE in (add-constraint :around
(db-class-slot-definition)) caused many-to-many relations errors. Test
MANY-TO-MANY reproduces the bug.

parent b97a890f
......@@ -90,7 +90,7 @@ be reverted.)"
(let ((class (slot-value slot 'sb-pcl::allocation-class)))
(with-class-connection (class)
(postmodern:execute (format nil "ALTER TABLE ~A ADD ~A;"
(class-name class)
(sql-ize (class-name class))
(defmethod add-constraint ((slot db-class-slot-definition) (constraint (eql :foreign-key)))
......@@ -110,6 +110,24 @@ metaclass set to HTML and the right connection-spec."
(defmany foo bar)
(defmany foo bar)))
(db-test (many-to-many :depends-on many-to-many-definition)
(defdao-example uno ()
((foo :type integer :accessor foo :initarg :foo)))
(defdao-example dos ()
((bar :type integer :accessor bar :initarg :bar)))
(defmany uno dos)
(let* ((uno (save-dao (make-instance 'uno :foo 1)))
(dos (make-and-save 'dos :bar 1)))
(finishes (relate uno dos))
(is (= 1 (length (uno dos))))
(is (= 1 (length (dos uno))))
(is (= 1 (bar (car (dos uno)))))))
(db-test (make-dao :depends-on dao-definition)
(defdao-example foo ()
((foo :type integer :initarg :foo :accessor foo)))
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