X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fclasses.lisp;h=7098ca2c81eafb294522578b648d896f0f20782f;hb=a4097e19c5157e87b9991549bc44f3ef598aeb90;hp=0babb5c57ecbcd9fa233668a22c421ce449daae1;hpb=a4449b6f1b9fb2471da255fc506bcad6f8feb220;p=clsql.git diff --git a/sql/classes.lisp b/sql/classes.lisp index 0babb5c..7098ca2 100644 --- a/sql/classes.lisp +++ b/sql/classes.lisp @@ -1,19 +1,20 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- -;;;; ====================================================================== -;;;; $Id: $ -;;;; ====================================================================== +;;;; ************************************************************************* ;;;; -;;;; Description ========================================================== -;;;; ====================================================================== +;;;; $Id$ ;;;; ;;;; Classes defining SQL expressions and methods for formatting the ;;;; appropriate SQL commands. ;;;; -;;;; ====================================================================== +;;;; 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-sys) - (defvar +empty-string+ "''") (defvar +null-string+ "NULL") @@ -21,14 +22,6 @@ (defvar *sql-stream* nil "stream which accumulates SQL output") -(defvar *default-schema* "UNCOMMONSQL") - -(defvar *object-schemas* (make-hash-table :test #'equal) - "Hash of schema name to class constituent lists.") - -(defun in-schema (schemaname) - (setf *default-schema* schemaname)) - (defun sql-output (sql-expr &optional database) (progv '(*sql-stream*) `(,(make-string-output-stream)) @@ -201,6 +194,16 @@ (format *sql-stream* "~s" alias)))) t) +#| +(defmethod database-output-sql ((self duration) database) + (declare (ignore database)) + (format nil "'~a'" (duration-timestring self))) + +(defmethod database-output-sql ((self money) database) + (database-output-sql (slot-value self 'odcl::units) database)) +|# + + (defmethod output-sql-hash-key ((expr sql-ident-table) &optional (database *default-database*)) (declare (ignore database)) @@ -641,13 +644,14 @@ uninclusive, and the args from that keyword to the end." (defmethod output-sql ((stmt sql-create-table) &optional (database *default-database*)) (flet ((output-column (column-spec) - (destructuring-bind (name type &rest constraints) + (destructuring-bind (name type &optional db-type &rest constraints) column-spec (let ((type (listify type))) (output-sql name database) (write-char #\Space *sql-stream*) (write-string - (database-get-type-specifier (car type) (cdr type) database) + (if (stringp db-type) db-type ; override definition + (database-get-type-specifier (car type) (cdr type) database)) *sql-stream*) (let ((constraints (database-constraint-statement constraints database)))