From 7e20a5285824bbbd2aa6fae61da73465ed2e8557 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 4 May 2004 20:43:51 +0000 Subject: [PATCH] r9227: 4 May 2004 Kevin Rosenberg (kevin@rosenberg.net) * sql/metaclasses.lisp: Properly store specified-type from direct-slot-definition and then store translated type in effective-slot-definition * sql/objects.lisp: Use specified type when invocating database-get-type-specifier. Return class for def-view-class. * base/basic-sql.lisp: Make :AUTO the default value for :RESULT-TYPES for MAP-QUERY and DO-QUERY. * sql/objects.lisp: Add bigint type * base/loop.lisp: Add placeholder (and warning) for object iteration * TODO: Need results for result-types for map-query and do-query --- ChangeLog | 9 +++++++-- TODO | 3 ++- base/basic-sql.lisp | 4 ++-- base/loop-extension.lisp | 21 ++++++++++++--------- sql/objects.lisp | 7 ++++++- sql/package.lisp | 3 ++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2511fc..3192063 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,14 @@ -3 May 2004 Kevin Rosenberg (kevin@rosenberg.net) +4 May 2004 Kevin Rosenberg (kevin@rosenberg.net) * sql/metaclasses.lisp: Properly store specified-type from direct-slot-definition and then store translated type in effective-slot-definition * sql/objects.lisp: Use specified type when invocating - database-get-type-specifier + database-get-type-specifier. Return class for def-view-class. + * base/basic-sql.lisp: Make :AUTO the default value for + :RESULT-TYPES for MAP-QUERY and DO-QUERY. + * sql/objects.lisp: Add bigint type + * base/loop.lisp: Add placeholder (and warning) for object iteration + * TODO: Need results for result-types for map-query and do-query 4 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) * Version 2.10.9 diff --git a/TODO b/TODO index f3852b0..7cff495 100644 --- a/TODO +++ b/TODO @@ -9,9 +9,10 @@ TESTS TO ADD * CACHE-TABLE-QUERIES * Test that ":db-kind :key" adds an index for that key. This is complicated by different backends showing autogenerated primary key in different ways. -* Test New universal and bigint types, add tests for other types such as duration and money * Large object testing +* Test bigint type * :db-constraint tests +* Test result-types for MAP-QUERY and DO-QUERY COMMONSQL SPEC diff --git a/base/basic-sql.lisp b/base/basic-sql.lisp index b0a2dad..cd9c177 100644 --- a/base/basic-sql.lisp +++ b/base/basic-sql.lisp @@ -61,7 +61,7 @@ pair.")) (values)) (defmacro do-query (((&rest args) query-expression - &key (database '*default-database*) (result-types nil)) + &key (database '*default-database*) (result-types :auto)) &body body) "Repeatedly executes BODY within a binding of ARGS on the attributes of each record resulting from QUERY-EXPRESSION. The @@ -94,7 +94,7 @@ default value of DATABASE is *DEFAULT-DATABASE*." (defun map-query (output-type-spec function query-expression &key (database *default-database*) - (result-types nil)) + (result-types :auto)) "Map the function over all tuples that are returned by the query in QUERY-EXPRESSION. The results of the function are collected as specified in OUTPUT-TYPE-SPEC and returned like in diff --git a/base/loop-extension.lisp b/base/loop-extension.lisp index f8129b5..a78086b 100644 --- a/base/loop-extension.lisp +++ b/base/loop-extension.lisp @@ -2,22 +2,16 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: loop-extension.lisp -;;;; Purpose: Extensions to the Loop macro for CMUCL -;;;; Programmer: Pierre R. Mai +;;;; Name: loop-extension.lisp +;;;; Purpose: Extensions to the Loop macro for CLSQL ;;;; -;;;; Copyright (c) 1999-2001 Pierre R. Mai +;;;; Copyright (c) 2001-2004 Kevin Rosenberg and (c) 1999-2001 Pierre R. Mai ;;;; ;;;; $Id$ -;;;; -;;;; The functions in this file were orignally distributed in the -;;;; MaiSQL package in the file sql/sql.cl ;;;; ************************************************************************* (in-package #:cl-user) -;;;; MIT-LOOP extension - #+(or allegro sbcl) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:ansi-loop @@ -56,6 +50,10 @@ (unless from-phrase (setq from-phrase '(clsql-base:*default-database*))) (cond + ;; Object query resulting in a list of returned object instances + ((consp in-phrase) + (error "object query not yet supported")) + ((consp variable) (let ((query-var (ansi-loop::loop-gentemp 'loop-record-)) (db-var (ansi-loop::loop-gentemp 'loop-record-database-)) @@ -147,7 +145,12 @@ (error "Missing OF or IN iteration path.")) (unless from-phrase (setq from-phrase '(clsql-base:*default-database*))) + (cond + ;; Object query resulting in a list of returned object instances + ((consp in-phrase) + (error "Object query not yet supported.")) + ((consp iter-var) (let ((query-var (gensym "LOOP-RECORD-")) (db-var (gensym "LOOP-RECORD-DATABASE-")) diff --git a/sql/objects.lisp b/sql/objects.lisp index 78d7044..33aab57 100644 --- a/sql/objects.lisp +++ b/sql/objects.lisp @@ -170,7 +170,8 @@ superclass of the newly-defined View Class." ,@(if (find :metaclass `,cl-options :key #'car) `,cl-options (cons '(:metaclass clsql-sys::standard-db-class) `,cl-options))) - (finalize-inheritance (find-class ',class)))) + (finalize-inheritance (find-class ',class)) + (find-class ',class))) (defun keyslots-for-class (class) (slot-value class 'key-slots)) @@ -465,6 +466,10 @@ superclass of the newly-defined View Class." (format nil "INT(~A)" (car args)) "INT")) +(deftype bigint () + "An integer larger than a 32-bit integer, this width may vary by SQL implementation." + 'integer) + (defmethod database-get-type-specifier ((type (eql 'bigint)) args database) (declare (ignore args database)) "BIGINT") diff --git a/sql/package.lisp b/sql/package.lisp index 45b6303..952825e 100644 --- a/sql/package.lisp +++ b/sql/package.lisp @@ -373,7 +373,8 @@ #:set-sequence-position ; table xx ;;OODDL #:view-table ; metaclass x - #:universal-time ; objects xx + #:universal-time ; objects xx + #:bigint ;;OODML #:add-to-relation ; objects x #:remove-from-relation ; objects x -- 2.34.1