+ ;; tests normalisedp update-instance-from-records
+ (deftest :oodml/update-instance/3
+ (values
+ (with-output-to-string (out)
+ (format out "~a ~a ~a ~a"
+ (slot-value theme2 'theme-id)
+ (slot-value theme2 'title)
+ (slot-value theme2 'vars)
+ (slot-value theme2 'doc)))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "Altered title"))
+ :where [= [node-id] 7])
+ (clsql:update-records [setting] :av-pairs '(([vars] "Altered vars"))
+ :where [= [setting-id] 7])
+ (clsql:update-records [theme] :av-pairs '(([doc] "Altered doc"))
+ :where [= [theme-id] 7])
+ (clsql:update-instance-from-records theme2)
+ (with-output-to-string (out)
+ (format out "~a ~a ~a ~a"
+ (slot-value theme2 'theme-id)
+ (slot-value theme2 'title)
+ (slot-value theme2 'vars)
+ (slot-value theme2 'doc))))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "theme-2"))
+ :where [= [node-id] 7])
+ (clsql:update-records [setting] :av-pairs '(([vars] nil))
+ :where [= [setting-id] 7])
+ (clsql:update-records [theme] :av-pairs '(([doc] "second theme"))
+ :where [= [theme-id] 7])
+ (clsql:update-instance-from-records theme2)
+ (with-output-to-string (out)
+ (format out "~a ~a ~a ~a"
+ (slot-value theme2 'theme-id)
+ (slot-value theme2 'title)
+ (slot-value theme2 'vars)
+ (slot-value theme2 'doc)))))
+ "7 theme-2 NIL second theme"
+ "7 Altered title Altered vars Altered doc"
+ "7 theme-2 NIL second theme")
+
+ (deftest :oodml/update-instance/4
+ (values
+ (progn
+ (setf loc2 (car (clsql:select 'location
+ :where [= [node-id] 9]
+ :flatp t :caching nil)))
+ (with-output-to-string (out)
+ (format out "~a ~a"
+ (slot-value loc2 'node-id)
+ (slot-value loc2 'title))))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "Altered title"))
+ :where [= [node-id] 9])
+ (clsql:update-instance-from-records loc2)
+ (with-output-to-string (out)
+ (format out "~a ~a"
+ (slot-value loc2 'node-id)
+ (slot-value loc2 'title))))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "location-2"))
+ :where [= [node-id] 9])
+ (clsql:update-instance-from-records loc2)
+ (with-output-to-string (out)
+ (format out "~a ~a"
+ (slot-value loc2 'node-id)
+ (slot-value loc2 'title)))))
+ "9 location-2"
+ "9 Altered title"
+ "9 location-2")
+
+ (deftest :oodml/update-instance/5
+ (values
+ (with-output-to-string (out)
+ (format out "~a ~a ~a"
+ (slot-value subloc2 'subloc-id)
+ (slot-value subloc2 'title)
+ (slot-value subloc2 'loc)))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "Altered title"))
+ :where [= [node-id] 11])
+ (clsql:update-records [subloc] :av-pairs '(([loc] "Altered loc"))
+ :where [= [subloc-id] 11])
+ (clsql:update-instance-from-records subloc2)
+ (with-output-to-string (out)
+ (format out "~a ~a ~a"
+ (slot-value subloc2 'subloc-id)
+ (slot-value subloc2 'title)
+ (slot-value subloc2 'loc))))
+ (progn
+ (clsql:update-records [node] :av-pairs '(([title] "subloc-2"))
+ :where [= [node-id] 11])
+ (clsql:update-records [subloc] :av-pairs '(([loc] "second subloc"))
+ :where [= [subloc-id] 11])
+ (clsql:update-instance-from-records subloc2)
+ (with-output-to-string (out)
+ (format out "~a ~a ~a"
+ (slot-value subloc2 'subloc-id)
+ (slot-value subloc2 'title)
+ (slot-value subloc2 'loc)))))
+ "11 subloc-2 second subloc"
+ "11 Altered title Altered loc"
+ "11 subloc-2 second subloc")
+
+ ;; tests update-slot-from-record with normalisedp stuff
+ (deftest :oodml/update-instance/6
+ (values
+ (slot-value theme1 'doc)
+ (slot-value theme1 'vars)
+ (progn
+ (clsql:update-records [theme]
+ :av-pairs '(([doc] "altered doc"))
+ :where [= [theme-id] 6])
+ (clsql:update-slot-from-record theme1 'doc)
+ (slot-value theme1 'doc))
+ (progn
+ (clsql:update-records [setting]
+ :av-pairs '(([vars] "altered vars"))
+ :where [= [setting-id] 6])
+ (clsql:update-slot-from-record theme1 'vars)
+ (slot-value theme1 'vars))
+ (progn
+ (clsql:update-records [theme]
+ :av-pairs '(([doc] "first theme"))
+ :where [= [theme-id] 6])
+ (clsql:update-slot-from-record theme1 'doc)
+ (slot-value theme1 'doc))
+ (progn
+ (clsql:update-records [setting]
+ :av-pairs '(([vars] "empty"))
+ :where [= [setting-id] 6])
+ (clsql:update-slot-from-record theme1 'vars)
+ (slot-value theme1 'vars)))
+ "first theme" "empty"
+ "altered doc" "altered vars"
+ "first theme" "empty")
+
+ (deftest :oodml/update-instance/7
+ (values
+ (slot-value loc2 'title)
+ (slot-value subloc2 'loc)
+ (progn
+ (clsql:update-records [node]
+ :av-pairs '(([title] "altered title"))
+ :where [= [node-id] 9])
+ (clsql:update-slot-from-record loc2 'title)
+ (slot-value loc2 'title))
+ (progn
+ (clsql:update-records [subloc]
+ :av-pairs '(([loc] "altered loc"))
+ :where [= [subloc-id] 11])
+ (clsql:update-slot-from-record subloc2 'loc)
+ (slot-value subloc2 'loc))
+ (progn
+ (clsql:update-records [node]
+ :av-pairs '(([title] "location-2"))
+ :where [= [node-id] 9])
+ (clsql:update-slot-from-record loc2 'title)
+ (slot-value loc2 'title))
+ (progn
+ (clsql:update-records [subloc]
+ :av-pairs '(([loc] "second subloc"))
+ :where [= [subloc-id] 11])
+ (clsql:update-slot-from-record subloc2 'loc)
+ (slot-value subloc2 'loc)))
+ "location-2" "second subloc"
+ "altered title" "altered loc"
+ "location-2" "second subloc")