X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fmetaclasses.lisp;h=a9e3ccd84efe2290fdd74e1f705e203981472634;hb=1eb686cfa4935e1252b2813ec6391bd781e88508;hp=bed60eeea4825fca492dbd2ebc62cf0943dc07a3;hpb=5ed1f05543cbd24b3f2bb735f2cfc03ea85e51ec;p=clsql.git diff --git a/sql/metaclasses.lisp b/sql/metaclasses.lisp index bed60ee..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. @@ -103,6 +101,14 @@ (pop-arg mylist)) newlist)) +(defun set-view-table-slot (class base-table) + (setf (view-table class) + (table-name-from-arg (or (and base-table + (if (listp base-table) + (car base-table) + base-table)) + (class-name class))))) + (defmethod initialize-instance :around ((class standard-db-class) &rest all-keys &key direct-superclasses base-table @@ -122,12 +128,7 @@ direct-superclasses) (remove-keyword-arg all-keys :direct-superclasses))) (call-next-method)) - (setf (view-table class) - (table-name-from-arg (or (and base-table - (if (listp base-table) - (car base-table) - base-table)) - (class-name class)))) + (set-view-table-slot class base-table) (register-metaclass class (nth (1+ (position :direct-slots all-keys)) all-keys)))) @@ -138,12 +139,7 @@ &allow-other-keys) (let ((root-class (find-class 'standard-db-object nil)) (vmc 'standard-db-class)) - (setf (view-table class) - (table-name-from-arg (sql-escape (or (and base-table - (if (listp base-table) - (car base-table) - base-table)) - (class-name class))))) + (set-view-table-slot class base-table) (setf (view-class-qualifier class) (car qualifier)) (if (and root-class (not (equal class root-class))) @@ -429,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