[elephant-cvs] CVS elephant/src/db-clsql

rread rread at common-lisp.net
Sun Feb 18 21:08:16 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/db-clsql
In directory clnet:/tmp/cvs-serv13893

Modified Files:
	sql-controller.lisp 
Log Message:
Fixing kevalue typo, and trying to make SQLite3 warnings less painful.


--- /project/elephant/cvsroot/elephant/src/db-clsql/sql-controller.lisp	2007/02/14 22:39:10	1.19
+++ /project/elephant/cvsroot/elephant/src/db-clsql/sql-controller.lisp	2007/02/18 21:08:16	1.20
@@ -290,27 +290,38 @@
   ;; the table, as long as we have the rights we need!
   (clsql:table-exists-p [version] :database con :owner :all)
   )
-
+(defun sqlite3-harmless-read (sc)
+  (let ((con (controller-db sc)))
+    (if
+     (equal 
+      (car (cadr (controller-spec sc)))
+      :sqlite3)
+     (handler-case 
+	 (clsql:query "select count(*) from keyvalue")
+       ((clsql-sys::sql-database-error () nil)
+	   )
+       )
+     )
+    ))
 (defun create-version-table (sc)
   (let ((con (controller-db sc)))
     (clsql::create-table [version]
-		       '(
-			 ([dbversion] text :not-null)
-			 ) :database con
-		       )
-   (if (and (clsql:table-exists-p [keyvlaue] :database con :owner :all)
-	    (= 0 (caar (clsql:query "select count(*) from keyvalue"))))
-	  (clsql::insert-records :into [version]
-				 :attributes '(dbversion)
-				 :values (list (format nil "~A" *elephant-code-version*))
-				 :database con)
-	  (clsql::insert-records :into [version]
-				 :attributes '(dbversion)
-				 :values (list (format nil "~A" '(0 6 0)))
-				 :database con)
-	  )
-      )
-    )
+			 '(
+			   ([dbversion] text :not-null)
+			   ) :database con
+			 )
+    (sqlite3-harmless-read sc)
+    (let ((version 
+	   (if (clsql:table-exists-p [keyvlaue] :database con :owner :all)
+	       (if (= 0 (caar (clsql:query "select count(*) from keyvalue")))
+		   *elephant-code-version*
+		   '(0 6 0))
+	       *elephant-code-version*)))
+      (clsql::insert-records :into [version]
+			     :attributes '(dbversion)
+			     :values (list (format nil "~A" version))
+			     :database con)
+      )))
 
 ;; These functions are probably not cross-database portable...
 (defun keyvalue-table-exists (con)
@@ -358,6 +369,7 @@
     (if (supports-sequence sc) 
 	(progn
 	  (clsql::create-sequence [serial] :database con)
+	  (sqlite3-harmless-read sc)
 	  (clsql::query
 	   (format nil "create table keyvalue (
  pk integer PRIMARY KEY DEFAULT nextval('serial'),
@@ -376,7 +388,7 @@
 			     ) 
 			   :database con)
       )
-
+    (sqlite3-harmless-read sc)
 ;;   	      :constraints '("PRIMARY KEY (clctn_id key)"
 ;;   				     "UNIQUE (clctn_id,key)")
 
@@ -402,6 +414,7 @@
   (clsql:create-index [idx_both] :on [keyvalue]
 		      :attributes '([clctn_id] [key])
 		      :database con)
+    (sqlite3-harmless-read sc)
   ;;)
   ))
 
@@ -420,7 +433,6 @@
 	  (read-from-string (caar tuples))
 	  nil))))
 
-
 (defmethod open-controller ((sc sql-store-controller)
 			    ;; At present these three have no meaning
 			    &key 




More information about the Elephant-cvs mailing list