Changes to more broadly support auto-increment. new odbc-postgresql-database type
[clsql.git] / tests / ds-nodes.lisp
index bb43ff09de8579b126f4052cf9c8ac829b37f828..098c742d7f49620e110ea7fc71c4231b03974514 100644 (file)
@@ -1,6 +1,6 @@
 (in-package #:clsql-tests)
 
-#.(clsql:locally-enable-sql-reader-syntax)
+(clsql-sys:file-enable-sql-reader-syntax)
 
 (defparameter basenode nil)
 (defparameter derivednode1 nil)
@@ -18,7 +18,6 @@
 (defparameter subloc2 nil)
 
 
-
 ;; classes for testing the normalizedp stuff
 (def-view-class node ()
   ((node-id :accessor node-id :initarg :node-id
 
 (def-view-class setting (node)
   ((setting-id :accessor setting-id :initarg :setting-id
-               :type integer :db-kind :key :db-constraints (:not-null))
+               :type integer :db-kind :key :db-constraints (:not-null ))
    (vars :accessor vars :initarg :vars :type (varchar 240)))
   (:normalizedp t))
 
 (def-view-class user (node)
   ((user-id :accessor user-id :initarg :user-id
-            :type integer :db-kind :key :db-constraints (:not-null))
+            :type integer :db-kind :key :db-constraints (:not-null ))
    (nick :accessor nick :initarg :nick :type (varchar 64)))
+  (:base-table "nodeuser")
   (:normalizedp t))
 
 (def-view-class theme (setting)
   ((theme-id :accessor theme-id :initarg :theme-id
-             :type integer :db-kind :key :db-constraints (:not-null))
+             :type integer :db-kind :key :db-constraints (:not-null ))
    (doc :accessor doc :initarg :doc :type (varchar 240)))
   (:normalizedp t))
 
@@ -56,7 +56,7 @@
 
 (def-view-class subloc (location)
   ((subloc-id :accessor subloc-id :initarg :subloc-id
-             :type integer :db-kind :key :db-constraints (:not-null))
+             :type integer :db-kind :key :db-constraints (:not-null ))
    (loc :accessor loc :initarg :loc :type (varchar 64)))
   (:normalizedp t))
 
 
 (defun initialize-ds-nodes ()
   ;;  (start-sql-recording :type :both)
-  (let ((*backend-warning-behavior*
-         (if (member *test-database-type* '(:postgresql :postgresql-socket))
-             :ignore
-            :warn)))
-    (mapc #'clsql:create-view-from-class
-         '(node setting user theme location subloc)))
+  (mapc #'clsql:create-view-from-class
+        '(node setting user theme location subloc))
 
   (setq *test-start-utime* (get-universal-time))
   (let* ((*db-auto-sync* t))
     (setf  node (make-instance 'node
-                              :title "Bare node")
-          setting1 (make-instance 'setting
-                                  :title "Setting1"
-                                  :vars "var 1")
-          setting2 (make-instance 'setting
-                                  :title "Setting2"
-                                  :vars "var 2")
-          user1 (make-instance 'user
-                               :title "user-1"
-                               :nick "first user")
-          user2 (make-instance 'user
-                               :title "user-2"
-                               :nick "second user")
-          theme1 (make-instance 'theme
-                                :title "theme-1"
-                                :vars "empty"
-                                :doc "first theme")
-          theme2 (make-instance 'theme
-                                :title "theme-2"
-                                :doc "second theme")
-         loc1 (make-instance 'location
-                              :title "location-1")
-         loc2 (make-instance 'location
-                              :title "location-2")
-         subloc1 (make-instance 'subloc
-                                :title "subloc-1"
-                                :loc "a subloc")
-         subloc2 (make-instance 'subloc
-                                :title "subloc-2"
-                                :loc "second subloc"))))
+                               :title "Bare node")
+           setting1 (make-instance 'setting
+                                   :title "Setting1"
+                                   :vars "var 1")
+           setting2 (make-instance 'setting
+                                   :title "Setting2"
+                                   :vars "var 2")
+           user1 (make-instance 'user
+                                :title "user-1"
+                                :nick "first user")
+           user2 (make-instance 'user
+                                :title "user-2"
+                                :nick "second user")
+           theme1 (make-instance 'theme
+                                 :title "theme-1"
+                                 :vars "empty"
+                                 :doc "first theme")
+           theme2 (make-instance 'theme
+                                 :title "theme-2"
+                                 :doc "second theme")
+           loc1 (make-instance 'location
+                               :title "location-1")
+           loc2 (make-instance 'location
+                               :title "location-2")
+           subloc1 (make-instance 'subloc
+                                  :title "subloc-1"
+                                  :loc "a subloc")
+           subloc2 (make-instance 'subloc
+                                  :title "subloc-2"
+                                  :loc "second subloc"))))
 
 
 
    (:setup initialize-ds-nodes)
    (:cleanup (lambda ()
               (mapc #'clsql-sys:drop-view-from-class
-                    '(node setting user theme location subloc)))))
+                    '(node setting user theme location subloc))
+              (ignore-errors
+                (clsql-sys:execute-command "DROP TABLE nodeuser")
+                (mapc #'clsql-sys:drop-sequence
+                      '(node_node_id_seq setting_setting_id_seq subloc_subloc_id_seq
+                        theme_theme_id_seq nodeuser_user_id_seq)
+                      )))))
 
-#.(clsql:restore-sql-reader-syntax-state)