database-consistent-with-specification test case and partial bugfix
Wed Nov 7 03:59:04 PST 2007 Ryszard Szopa <ryszard.szopa@gmail.com>
* database-consistent-with-specification test case and partial bugfix
d-c-w-s causes an error when you provide as a type of a column
things like (string 5). I partially fixed it (it still throws an
unnecessary condition, but a good fix is srill necessary.
diff -rN -u old-submarine/db.lisp new-submarine/db.lisp
--- old-submarine/db.lisp 2014-07-29 09:49:00.000000000 -0700
+++ new-submarine/db.lisp 2014-07-29 09:49:01.000000000 -0700
@@ -160,10 +160,14 @@
(:method ((class db-class))
(let ((class-name (class-name class)))
(labels
- ((prepare-field (field)
+ ((ensure-list (x)
+ (if (listp x)
+ x
+ (list x)))
+ (prepare-field (field)
(list (sql-ize (slot-definition-name field))
- (string-downcase (sql-type-name (or (and (foreign-type-p field) 'integer)
- (slot-definition-type field))))))
+ (string-downcase (apply #'sql-type-name (ensure-list (or (and (foreign-type-p field) 'integer)
+ (slot-definition-type field)))))))
(extract-type (field)
(read-from-string (second field)))
(field= (field1 field2)
@@ -227,4 +231,4 @@
;;; not be misrepresented as being the original software.
;;;
;;; 3. This notice may not be removed or altered from any source
-;;; distribution.
\ No newline at end of file
+;;; distribution.
diff -rN -u old-submarine/submarine-tests.lisp new-submarine/submarine-tests.lisp
--- old-submarine/submarine-tests.lisp 2014-07-29 09:49:01.000000000 -0700
+++ new-submarine/submarine-tests.lisp 2014-07-29 09:49:01.000000000 -0700
@@ -56,6 +56,13 @@
(defdao-example foo ()
((foo :type integer)))))
+(db-test (database-consistent-with-specification :depends-on dao-definition)
+ (defdao-example trigram ()
+ ((name :type (string 3) :accessor trigram-of :not-null t :initarg :trigram)
+ ))
+ (finishes (with-class-connection ((find-class 'trigram))
+ (submarine::database-consistent-with-specification (find-class 'trigram)))))
+
(db-test (dao-definition-with-foreign-key :depends-on dao-definition)
(defdao-example foo ()
((foo :type integer)))