* base/conditions.lisp: Added CLSQL-ACCESS-ERROR
* base/utils.lisp: Fix use of position-char.
Add COMMAND-OUTPUT used by backends for running
- shell commands.
- * base/loop-extension.lisp: Rework packages
+ external programs. Fix parsing of SQL*NET-compatible
+ connection-specs.
+ * base/loop-extension.lisp: Simplify package use
for Lispworks and Allegro
* db-*/*-sql.lisp: Added DATABASE-CREATE,
DATABASE-DESTORY, PROBE-DATABASE methods
testing with empty database
* tests/test-connection.lisp: Add tests for
parsing of string connection-specs
+ * examples/run-tests.sh: New file for running
+ test suite on all installed CL implementations
+ * examples/clsql-tutorial.lisp: moved from
+ doc directory
+ * examples/dot.clsql-tests.config: New file
+ giving an example test configuration
+ * test/README: Add notes about rtest/ptester
+ downloads and link to sample test configuration file.
10 Apr 2004 Kevin Rosenberg (kevin@rosenberg.net)
* Version 2.5.1 released:
-These tests require the setup of a configuration file with account
-information for MySQL and PostgreSQL SQL servers. Additionally, the
-Debian package acl-installer must be installed and a license
-downloaded to use the AODBC tests.
-
-Furthermore, if you are not using the Debian package of CLSQL, these
-tests require the downloading of the rtest and ptester packages from
-http://files.b9.com/.
-
This test suite looks for a configuration file named
-".clsql-test.config" located in the users home directory.
-
-This file contains a single a-list that specifies the connection
- specs for each database type to be tested. For example, to test all
-platforms, a sample file might look like this:
+".clsql-test.config" located in the users home directory. This file
+contains a single assoc-list that specifies the connection specs for
+each database type to be tested. There is an example file in contained
+in CLSQL's examples directory.
-((:mysql ("localhost" "a-mysql-db" "user1" "secret"))
- (:aodbc ("my-dsn" "a-user" "pass"))
- (:postgresql ("localhost" "another-db" "user2" "dont-tell"))
- (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password")))
+These tests require the downloading of the rtest and ptester packages
+from http://files.b9.com/.
;;;; Created: 30/03/2004
;;;; Updated: $Id$
;;;;
-;;;; $Id$
+;;;; This file is part of CLSQL.
;;;;
;;;; CLSQL users are granted the rights to distribute and use this software
;;;; as governed by the terms of the Lisp Lesser GNU Public License
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
-;;;; ======================================================================
(in-package #:cl-user)
(defpackage #:clsql-tests-system (:use #:asdf #:cl))
(defmethod database-create (connection-spec (type (eql :postgresql-socket)))
- (error 'clsql-access-error
- :connection-spec connection-spec
- :database-type type
- :error "Unable to create databases on a socket connection."))
+ (destructuring-bind (host name user password) connection-spec
+ (let ((database (database-connect (list host "template1" user password)
+ type)))
+ (unwind-protect
+ (execute-command (format nil "create database ~A" name))
+ (database-disconnect database)))))
(defmethod database-destroy (connection-spec (type (eql :postgresql-socket)))
- (error 'clsql-access-error
- :connection-spec connection-spec
- :database-type type
- :error "Unable to create databases on a socket connection."))
+ (destructuring-bind (host name user password) connection-spec
+ (let ((database (database-connect (list host "template1" user password)
+ type)))
+ (unwind-protect
+ (execute-command (format nil "drop database ~A" name))
+ (database-disconnect database)))))
(defmethod database-probe (connection-spec (type (eql :postgresql-socket)))
(destructuring-bind (host name user password) connection-spec
dh_testroot -i
# dh_installdebconf -i
dh_installdocs -i
- dh_installexamples -i
+ dh_installexamples -i examples
dh_installmenu -i
# dh_installlogrotate -i
# dh_installemacsen -i
+++ /dev/null
-(asdf:operate 'asdf:load-op 'clsql)
-
-(in-package #:clsql-user)
-
-;; You must set these variables to appropriate values.
-(defvar *tutorial-database-type* nil
- "Possible values are :postgresql,:postgresql-socket :mysql or :sqlite")
-(defvar *tutorial-database-name* ""
- "The name of the database we will work in.")
-(defvar *tutorial-database-user* ""
- "The name of the database user we will work as.")
-(defvar *tutorial-database-server* ""
- "The name of the database server if required")
-(defvar *tutorial-database-password* ""
- "The password if required")
-
-(clsql:def-view-class employee ()
- ((emplid
- :db-kind :key
- :db-constraints :not-null
- :nulls-ok nil
- :type integer
- :initarg :emplid)
- (first-name
- :accessor first-name
- :type (string 30)
- :initarg :first-name)
- (last-name
- :accessor last-name
- :type (string 30)
- :initarg :last-name)
- (email
- :accessor employee-email
- :type (string 100)
- :nulls-ok t
- :initarg :email)
- (companyid
- :type integer)
- (company
- :accessor employee-company
- :db-kind :join
- :db-info (:join-class company
- :home-key companyid
- :foreign-key companyid
- :set nil))
- (managerid
- :type integer
- :nulls-ok t)
- (manager
- :accessor employee-manager
- :db-kind :join
- :db-info (:join-class employee
- :home-key managerid
- :foreign-key emplid
- :set nil)))
- (:base-table employee))
-
-(clsql:def-view-class company ()
- ((companyid
- :db-type :key
- :db-constraints :not-null
- :type integer
- :initarg :companyid)
- (name
- :type (string 100)
- :initarg :name)
- (presidentid
- :type integer)
- (president
- :reader president
- :db-kind :join
- :db-info (:join-class employee
- :home-key presidentid
- :foreign-key emplid
- :set nil))
- (employees
- :reader company-employees
- :db-kind :join
- :db-info (:join-class employee
- :home-key companyid
- :foreign-key companyid
- :set t)))
- (:base-table company))
-
-;; Connect to the database (see the CLSQL documentation for vendor
-;; specific connection specs).
-(clsql:connect `(,*tutorial-database-server*
- ,*tutorial-database-name*
- ,*tutorial-database-user*
- ,*tutorial-database-password*)
- :database-type *tutorial-database-type*)
-
-;; Record the sql going out, helps us learn what is going
-;; on behind the scenes
-(clsql:start-sql-recording)
-
-;; Create the tables for our view classes
-;; First we drop them, ignoring any errors
-(ignore-errors
- (clsql:drop-view-from-class 'employee)
- (clsql:drop-view-from-class 'company))
-
-(clsql:create-view-from-class 'employee)
-(clsql:create-view-from-class 'company)
-
-
-;; Create some instances of our view classes
-(defvar employee1 (make-instance 'employee
- :emplid 1
- :first-name "Vladamir"
- :last-name "Lenin"
- :email "lenin@soviet.org"))
-
-(defvar company1 (make-instance 'company
- :companyid 1
- :name "Widgets Inc."))
-
-
-(defvar employee2 (make-instance 'employee
- :emplid 2
- :first-name "Josef"
- :last-name "Stalin"
- :email "stalin@soviet.org"))
-
-;; Lenin manages Stalin (for now)
-(clsql:add-to-relation employee2 'manager employee1)
-
-;; Lenin and Stalin both work for Widgets Inc.
-(clsql:add-to-relation company1 'employees employee1)
-(clsql:add-to-relation company1 'employees employee2)
-
-;; Lenin is president of Widgets Inc.
-(clsql:add-to-relation company1 'president employee1)
-
-(clsql:update-records-from-instance employee1)
-(clsql:update-records-from-instance employee2)
-(clsql:update-records-from-instance company1)
-
-;; lets us use the functional
-;; sql interface
-(clsql:locally-enable-sql-reader-syntax)
-
-
-(format t "The email address of ~A ~A is ~A"
- (first-name employee1)
- (last-name employee1)
- (employee-email employee1))
-
-(setf (employee-email employee1) "lenin-nospam@soviets.org")
-
-;; Update the database
-(clsql:update-records-from-instance employee1)
-
-(let ((new-lenin (car
- (clsql:select 'employee
- :where [= [slot-value 'employee 'emplid] 1]))))
- (format t "His new email is ~A"
- (employee-email new-lenin)))
-
-
-;; Some queries
-
-;; all employees
-(clsql:select 'employee)
-;; all companies
-(clsql:select 'company)
-
-;; employees named Lenin
-(clsql:select 'employee :where [= [slot-value 'employee 'last-name]
- "Lenin"])
-
-(clsql:select 'company :where [= [slot-value 'company 'name]
- "Widgets Inc."])
-
-;; Employees of Widget's Inc.
-(clsql:select 'employee
- :where [and [= [slot-value 'employee 'companyid]
- [slot-value 'company 'companyid]]
- [= [slot-value 'company 'name]
- "Widgets Inc."]])
-
-;; Same thing, except that we are using the employee
-;; relation in the company view class to do the join for us,
-;; saving us the work of writing out the SQL!
-(company-employees company1)
-
-;; President of Widgets Inc.
-(president company1)
-
-;; Manager of Josef Stalin
-(employee-manager employee2)
--- /dev/null
+(asdf:operate 'asdf:load-op 'clsql)
+
+(in-package #:clsql-user)
+
+;; You must set these variables to appropriate values.
+(defvar *tutorial-database-type* nil
+ "Possible values are :postgresql,:postgresql-socket :mysql or :sqlite")
+(defvar *tutorial-database-name* ""
+ "The name of the database we will work in.")
+(defvar *tutorial-database-user* ""
+ "The name of the database user we will work as.")
+(defvar *tutorial-database-server* ""
+ "The name of the database server if required")
+(defvar *tutorial-database-password* ""
+ "The password if required")
+
+(clsql:def-view-class employee ()
+ ((emplid
+ :db-kind :key
+ :db-constraints :not-null
+ :nulls-ok nil
+ :type integer
+ :initarg :emplid)
+ (first-name
+ :accessor first-name
+ :type (string 30)
+ :initarg :first-name)
+ (last-name
+ :accessor last-name
+ :type (string 30)
+ :initarg :last-name)
+ (email
+ :accessor employee-email
+ :type (string 100)
+ :nulls-ok t
+ :initarg :email)
+ (companyid
+ :type integer)
+ (company
+ :accessor employee-company
+ :db-kind :join
+ :db-info (:join-class company
+ :home-key companyid
+ :foreign-key companyid
+ :set nil))
+ (managerid
+ :type integer
+ :nulls-ok t)
+ (manager
+ :accessor employee-manager
+ :db-kind :join
+ :db-info (:join-class employee
+ :home-key managerid
+ :foreign-key emplid
+ :set nil)))
+ (:base-table employee))
+
+(clsql:def-view-class company ()
+ ((companyid
+ :db-type :key
+ :db-constraints :not-null
+ :type integer
+ :initarg :companyid)
+ (name
+ :type (string 100)
+ :initarg :name)
+ (presidentid
+ :type integer)
+ (president
+ :reader president
+ :db-kind :join
+ :db-info (:join-class employee
+ :home-key presidentid
+ :foreign-key emplid
+ :set nil))
+ (employees
+ :reader company-employees
+ :db-kind :join
+ :db-info (:join-class employee
+ :home-key companyid
+ :foreign-key companyid
+ :set t)))
+ (:base-table company))
+
+;; Connect to the database (see the CLSQL documentation for vendor
+;; specific connection specs).
+(clsql:connect `(,*tutorial-database-server*
+ ,*tutorial-database-name*
+ ,*tutorial-database-user*
+ ,*tutorial-database-password*)
+ :database-type *tutorial-database-type*)
+
+;; Record the sql going out, helps us learn what is going
+;; on behind the scenes
+(clsql:start-sql-recording)
+
+;; Create the tables for our view classes
+;; First we drop them, ignoring any errors
+(ignore-errors
+ (clsql:drop-view-from-class 'employee)
+ (clsql:drop-view-from-class 'company))
+
+(clsql:create-view-from-class 'employee)
+(clsql:create-view-from-class 'company)
+
+
+;; Create some instances of our view classes
+(defvar employee1 (make-instance 'employee
+ :emplid 1
+ :first-name "Vladamir"
+ :last-name "Lenin"
+ :email "lenin@soviet.org"))
+
+(defvar company1 (make-instance 'company
+ :companyid 1
+ :name "Widgets Inc."))
+
+
+(defvar employee2 (make-instance 'employee
+ :emplid 2
+ :first-name "Josef"
+ :last-name "Stalin"
+ :email "stalin@soviet.org"))
+
+;; Lenin manages Stalin (for now)
+(clsql:add-to-relation employee2 'manager employee1)
+
+;; Lenin and Stalin both work for Widgets Inc.
+(clsql:add-to-relation company1 'employees employee1)
+(clsql:add-to-relation company1 'employees employee2)
+
+;; Lenin is president of Widgets Inc.
+(clsql:add-to-relation company1 'president employee1)
+
+(clsql:update-records-from-instance employee1)
+(clsql:update-records-from-instance employee2)
+(clsql:update-records-from-instance company1)
+
+;; lets us use the functional
+;; sql interface
+(clsql:locally-enable-sql-reader-syntax)
+
+
+(format t "The email address of ~A ~A is ~A"
+ (first-name employee1)
+ (last-name employee1)
+ (employee-email employee1))
+
+(setf (employee-email employee1) "lenin-nospam@soviets.org")
+
+;; Update the database
+(clsql:update-records-from-instance employee1)
+
+(let ((new-lenin (car
+ (clsql:select 'employee
+ :where [= [slot-value 'employee 'emplid] 1]))))
+ (format t "His new email is ~A"
+ (employee-email new-lenin)))
+
+
+;; Some queries
+
+;; all employees
+(clsql:select 'employee)
+;; all companies
+(clsql:select 'company)
+
+;; employees named Lenin
+(clsql:select 'employee :where [= [slot-value 'employee 'last-name]
+ "Lenin"])
+
+(clsql:select 'company :where [= [slot-value 'company 'name]
+ "Widgets Inc."])
+
+;; Employees of Widget's Inc.
+(clsql:select 'employee
+ :where [and [= [slot-value 'employee 'companyid]
+ [slot-value 'company 'companyid]]
+ [= [slot-value 'company 'name]
+ "Widgets Inc."]])
+
+;; Same thing, except that we are using the employee
+;; relation in the company view class to do the join for us,
+;; saving us the work of writing out the SQL!
+(company-employees company1)
+
+;; President of Widgets Inc.
+(president company1)
+
+;; Manager of Josef Stalin
+(employee-manager employee2)
--- /dev/null
+;; -*- Mode: Lisp -*- ;; Emacs mode line
+;;
+;; Example CLSQL test configuration file
+;; Since this file is read by Lisp, it is okay to use
+;; comments in this file
+;; This file should be named .clsql-test.config and
+;; placed in your home directory
+
+((:mysql ("localhost" "a-mysql-db" "user1" "secret"))
+ (:aodbc ("my-dsn" "a-user" "pass"))
+ (:postgresql ("localhost" "another-db" "user2" "dont-tell"))
+ (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password"))
+ (:sqlite ("path-to-sqlite-db")))
+
--- /dev/null
+#!/bin/bash
+#
+# Run CLSQL tests on all installed CL implementations
+# Need to setup ~/.clsql-tests.config as show in
+# tests/test-init.lisp
+
+CMD='(asdf:operate (quote asdf:test-op) :clsql-classic)
+ (asdf:operate (quote asdf:test-op) :clsql)
+ #+allegro (excl:exit :quiet t)
+ #+clisp (#+lisp=cl ext:quit #-lisp=cl lisp:quit)
+ #+cmu (ext:quit)
+ #+lispworks (lw:quit)
+ #+openmcl (ccl:quit)
+ #+sbcl (sb-ext:quit))
+ #+scl (ext:quit)'
+
+
+
+ALLEGRO=alisp
+if [ "`which $ALLEGRO`" ]; then
+ echo "$CMD" | $ALLEGRO
+fi
+
+CMUCL=lisp
+if [ "`which $CMUCL`" ]; then
+ echo "$CMD" | $CMUCL
+fi
+
+LISPWORKS=lw-console
+#LISPWORKS=lispworks-4300
+if [ "`which $LISPWORKS`" ]; then
+ echo "$CMD" | $LISPWORKS
+fi
+
+OPENCML=openmcl
+if [ "`which $OPENMCL`" ]; then
+ echo "$CMD" | $OPENMCL
+fi
+
+SBCL=sbcl
+if [ "`which $SBCL`" ]; then
+ echo "$CMD" | $SBCL
+fi
* RUNNING THE REGRESSION SUITE
-Create a .clsql-tests.config file in your home directory.
-See test-init.lisp for the structure of the data.
+This test suite looks for a configuration file named
+".clsql-test.config" located in the users home directory. This file
+contains a single assoc-list that specifies the connection specs for
+each database type to be tested. There is an example file in
+contained in CLSQL's examples directory.
+
+These tests require the downloading of the rtest and ptester packages
+from http://files.b9.com/.
Load clsql.asd or put it somewhere where ASDF can find it
and call:
;;;; Authors: Marcus Pearce <m.t.pearce@city.ac.uk>, Kevin Rosenberg
;;;; Created: 30/03/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Tests for CLSQL database connections.
;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
(in-package #:clsql-tests)
;;;; Author: Marcus Pearce <m.t.pearce@city.ac.uk>
;;;; Created: 30/03/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Tests for the CLSQL Functional Data Definition Language
;;;; (FDDL).
-;;;;
+;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
(in-package #:clsql-tests)
;;;; Author: Marcus Pearce <m.t.pearce@city.ac.uk>
;;;; Created: 30/03/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Tests for the CLSQL Functional Data Manipulation Language
;;;; (FDML).
-;;;;
+;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
(in-package #:clsql-tests)
;;;; Authors: Marcus Pearce <m.t.pearce@city.ac.uk>, Kevin Rosenberg
;;;; Created: 30/03/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Initialisation utilities for running regression tests on CLSQL.
;;;;
;;;; ======================================================================
-;;; This test suite looks for a configuration file named ".clsql-test.config"
-;;; located in the users home directory.
-;;;
-;;; This file contains a single a-list that specifies the connection
-;;; specs for each database type to be tested. For example, to test all
-;;; platforms, a sample "test.config" may look like:
-;;;
-;;; ((:mysql ("localhost" "a-mysql-db" "user1" "secret"))
-;;; (:aodbc ("my-dsn" "a-user" "pass"))
-;;; (:postgresql ("localhost" "another-db" "user2" "dont-tell"))
-;;; (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password"))
-;;; (:sqlite ("path-to-sqlite-db")))
-
(in-package #:clsql-tests)
(defvar *rt-connection*)
;;;; Author: Marcus Pearce <m.t.pearce@city.ac.uk>
;;;; Created: 30/03/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Tests for the CLSQL Object Oriented Data Definition Language
;;;; (OODDL).
;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
;;;; Author: Marcus Pearce <m.t.pearce@city.ac.uk>
;;;; Created: 01/04/2004
;;;; Updated: $Id$
-;;;; ======================================================================
-;;;;
-;;;; Description ==========================================================
-;;;; ======================================================================
;;;;
;;;; Tests for the CLSQL Object Oriented Data Definition Language
;;;; (OODML).
;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; ======================================================================
(in-package #:clsql-tests)