Refactored find-all and build-object to be more readable, shorter and
[clsql.git] / tests / ds-nodes.lisp
index 2883b31bf924ade4a19e983dc9e8f3575044fc40..00c8af4484ed20c990ce32695f1ec3cc0801f306 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,8 +18,7 @@
 (defparameter subloc2 nil)
 
 
-
-;; classes for testing the normalisedp stuff
+;; classes for testing the normalizedp stuff
 (def-view-class node ()
   ((node-id :accessor node-id :initarg :node-id
             :type integer :db-kind :key
 
 (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 :auto-increment))
    (vars :accessor vars :initarg :vars :type (varchar 240)))
-  (:normalisedp t))
+  (: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 :auto-increment))
    (nick :accessor nick :initarg :nick :type (varchar 64)))
-  (:normalisedp t))
+  (: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 :auto-increment))
    (doc :accessor doc :initarg :doc :type (varchar 240)))
-  (:normalisedp t))
+  (:normalizedp t))
 
 ;; A class that uses only a superclass db table
 (def-view-class location (node)
   ()
   (:base-table node)
-  (:normalisedp t))
+  (:normalizedp t))
 
 (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 :auto-increment))
    (loc :accessor loc :initarg :loc :type (varchar 64)))
-  (:normalisedp t))
+  (:normalizedp t))
 
 
 
@@ -70,7 +70,6 @@
             :warn)))
     (mapc #'clsql:create-view-from-class
          '(node setting user theme location subloc)))
-    
 
   (setq *test-start-utime* (get-universal-time))
   (let* ((*db-auto-sync* t))
                                 :loc "a subloc")
          subloc2 (make-instance 'subloc
                                 :title "subloc-2"
-                                :loc "second subloc")))
-
-
-  )
+                                :loc "second subloc"))))
 
 
 
 
- (def-dataset *ds-employees*
-   (:setup initialize-ds-employees)
+ (def-dataset *ds-nodes*
+   (:setup initialize-ds-nodes)
    (:cleanup (lambda ()
               (mapc #'clsql-sys:drop-view-from-class
-                    '(employee company address employee-address
-                      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)