From 1eb686cfa4935e1252b2813ec6391bd781e88508 Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Fri, 4 Sep 2009 12:51:23 -0600 Subject: [PATCH] Rework initialize-instance for view-class-direct-slot-definition --- ChangeLog | 2 ++ sql/metaclasses.lisp | 36 +++++++++++------------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 714604d..762dd4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ (thanks to Stephen Compall) * sql/database.lisp: Use :verbose nil for asdf:operate invocation (Thanks to Mackram Raydan) + * sql/metaclasses.lisp: Rework initialize-instance for + view-class-direct-slot-definition (thanks to Stephen Compall) 31 Aug 2009 Kevin Rosenberg * sql/db-interface.lisp: Fix spelling error (thanks to diff --git a/sql/metaclasses.lisp b/sql/metaclasses.lisp index 2a0b4b9..a9e3ccd 100644 --- a/sql/metaclasses.lisp +++ b/sql/metaclasses.lisp @@ -1,8 +1,6 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id$ -;;;; ;;;; CLSQL metaclass for standard-db-objects created in the OODDL. ;;;; ;;;; This file is part of CLSQL. @@ -427,29 +425,17 @@ implementations." (car list) list)) -(defmethod initialize-instance :around ((obj view-class-direct-slot-definition) - &rest initargs) - (do* ((parsed (list obj)) - (name (first initargs) (first initargs)) - (val (second initargs) (second initargs)) - (type nil) - (db-constraints nil)) - ((null initargs) - (setq parsed - (append parsed - (list 'specified-type type - :type (compute-lisp-type-from-specified-type - type db-constraints)))) - (apply #'call-next-method parsed)) - (case name - (:db-constraints - (setq db-constraints val) - (setq parsed (append parsed (list name val)))) - (:type - (setq type val)) - (t - (setq parsed (append parsed (list name val))))) - (setq initargs (cddr initargs)))) +(defmethod initialize-instance :around + ((obj view-class-direct-slot-definition) + &rest initargs &key db-constraints db-kind type &allow-other-keys) + (when (and (not db-kind) (member :primary-key (listify db-constraints))) + (warn "Slot ~S constrained to be :primary-key, but not marked as :db-kind :key" + (slot-definition-name obj))) + (apply #'call-next-method obj + 'specified-type type + :type (compute-lisp-type-from-specified-type + type db-constraints) + initargs)) (defmethod compute-effective-slot-definition ((class standard-db-class) #+kmr-normal-cesd slot-name -- 2.34.1