Add support for :default in db constraints. make-constraint-description: use next...
[clsql.git] / tests / test-oodml.lisp
index 978d1fd732d6abefa6e6c76e1db47abc394e9e33..8aab53799e5da8ed482439adb5c7af76b53ecdb7 100644 (file)
          (slot-value a 'loc))))
   10 10 "subloc-1" "a subloc")
 
+(deftest :oodml/select/23
+    (with-dataset *ds-artists*
+      (length (clsql:select 'artist :flatp t :caching nil)))
+  0)
+
+
+
 ;; test retrieval is deferred
 (deftest :oodm/retrieval/1
     (with-dataset *ds-employees*
 ;; tests update-record-from-slot
 (deftest :oodml/update-records/2
     (with-dataset *ds-employees*
+      ;(start-sql-recording :type :both)
       (values
        (employee-email
         (car (clsql:select 'employee
                            :where [= 1 [slot-value 'employee 'emplid]]
                            :flatp t
                            :caching nil)))
-       (progn
-         (setf (slot-value employee1 'email) "lenin-nospam@soviet.org")
-         (clsql:update-record-from-slot employee1 'email)
+       (progn
+         (setf (slot-value employee1 'email) "lenin-nospam@soviet.org")
+         (clsql:update-record-from-slot employee1 'email)
          (employee-email
           (car (clsql:select 'employee
                              :where [= 1 [slot-value 'employee 'emplid]]
                                       :flatp t :caching nil))))
            (setf (slot-value sl 'title) "subloc-1")
            (setf (slot-value sl 'loc) "a subloc")
-           (clsql:update-record-from-slot sl '(title loc))
+           (clsql:update-record-from-slots sl '(title loc))
            (print-fresh-subloc)))))
   "10 subloc-1 a subloc"
   "10 Altered subloc title Altered loc"
 ;; (was failing in Postgresql at somepoint)
 (deftest :oodml/update-records/10
     (with-dataset *ds-employees*
-      (let ((emp (first (clsql:select 'employee :where [= [emplid] 1] :flatp T))))
+      (let ((emp (first (clsql:select 'employee :where [= [emplid] 1] :flatp t))))
        (setf (height emp) nil)
        (clsql-sys:update-record-from-slot emp 'height)
        (values
   ((42.0d0))
   ((24.13d0)))
 
+(deftest :oodml/update-records/11
+    (with-dataset *ds-artists*
+      (clsql:update-records-from-instance artist1)
+      (list (name artist1) (artist_id artist1)))
+  ("Mogwai" 1))
+
+(deftest :oodml/update-records/12
+    (with-dataset *ds-artists*
+      (clsql:update-records-from-instance artist1)
+      (list (name artist1) (genre artist1)))
+  ("Mogwai" "Unknown"))
 
 ;; tests update-instance-from-records
 (deftest :oodml/update-instance/1
           (print-subloc (sl)
             (format nil "~a: ~a"
                     (slot-value sl 'node-id) (slot-value sl 'loc))))
-       (with-dataset *ds-nodes*
-      (values
-       (print-loc loc2)
-       (print-subloc subloc2)
-       (progn
-         (clsql:update-records [node]
-                               :av-pairs '(([title] "altered title"))
-                               :where [= [node-id] 9])
-         (clsql:update-slot-from-record loc2 'title)
-         (print-loc loc2))
-       (progn
-         (clsql:update-records [subloc]
-                               :av-pairs '(([loc] "altered loc"))
-                               :where [= [subloc-id] 11])
-         (clsql:update-slot-from-record subloc2 'loc)
-         (print-subloc subloc2)))))
+      (with-dataset *ds-nodes*
+       (values
+         (print-loc loc2)
+         (print-subloc subloc2)
+         (progn
+           (clsql:update-records [node]
+                                 :av-pairs '(([title] "altered title"))
+                                 :where [= [node-id] 9])
+           (clsql:update-slot-from-record loc2 'title)
+           (print-loc loc2))
+         (progn
+           (clsql:update-records [subloc]
+                                 :av-pairs '(([loc] "altered loc"))
+                                 :where [= [subloc-id] 11])
+           (clsql:update-slot-from-record subloc2 'loc)
+           (print-subloc subloc2)))))
   "9: location-2" "11: second subloc"
   "9: altered title" "11: altered loc")
 
       (values
        (let ((inst (make-instance 'theme
                                   :title "test-theme" :vars "test-vars"
-                                  :doc "test-doc")))
+                                  :doc "test-doc"))
+              (*print-circle* nil))
          (setf (slot-value inst 'title) "alternate-test-theme")
          (format nil "~a ~a ~a ~a"
                  (or (select [title] :from [node]