Permalink
Browse files

added `find-driver' to find a subclass of <dbi-driver>.

  • Loading branch information...
fukamachi committed Oct 31, 2011
1 parent b108411 commit e281bb9f6ce14dbc58da41a52cea3f3f436a1f7b
Showing with 14 additions and 2 deletions.
  1. +2 −1 cl-dbi.asd
  2. +12 −1 src/driver.lisp
View
@@ -19,7 +19,8 @@
:author "Eitarow Fukamachi"
:license "LLGPL"
:depends-on (:cl-syntax
- :cl-syntax-annot)
+ :cl-syntax-annot
+ :closer-mop)
:components ((:module "src"
:components
((:file "dbi" :depends-on ("driver"))
View
@@ -5,7 +5,9 @@
(in-package :cl-user)
(defpackage dbi.driver
- (:use :cl))
+ (:use :cl)
+ (:import-from :c2mop
+ :class-direct-subclasses))
(in-package :dbi.driver)
(cl-syntax:use-syntax :annot)
@@ -43,6 +45,15 @@
(declare (ignore params name password))
(error "`make-connection' should be implemented in a subclass of `<dbi-driver>'."))
+@export
+(defun find-driver (driver-name)
+ (find-if
+ (lambda (class)
+ (or (string= driver-name (class-name class))
+ (string= (format nil "<DBI-DRIVER-~:(~A~)>" driver-name)
+ (class-name class))))
+ (c2mop:class-direct-subclasses (find-class '<dbi-driver>))))
+
@export
(defmethod execute-using-connection ((conn <dbi-connection>) (query <dbi-query>) params)
(declare (ignore params))

0 comments on commit e281bb9

Please sign in to comment.