b3baf30c79a45dafdaa174f285118fbabde5b1d1
[clsql.git] / db-mysql / mysql-objects.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:     mysql-objects.lisp
6 ;;;; Purpose:  CLSQL Object layer for MySQL
7 ;;;; Created:  May 2004
8 ;;;;
9 ;;;; CLSQL users are granted the rights to distribute and use this software
10 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
11 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
12 ;;;; *************************************************************************
13
14 (in-package #:clsql-mysql)
15
16 (defmethod database-get-type-specifier ((type symbol) args database
17                                         (db-type (eql :mysql)))
18   (declare (ignore args database db-type))
19   (case type
20     (wall-time "DATETIME")
21     (tinyint "TINYINT")
22     (smallint "SMALLINT")
23     (mediumint "MEDIUMINT")
24     (t (call-next-method))))
25
26 (defmethod read-sql-value (val (type (eql 'boolean)) database
27                            (db-type (eql :mysql)))
28   (declare (ignore database))
29   (etypecase val
30     (string (if (string= "0" val) nil t))
31     (integer (if (zerop val) nil t))))
32
33 (defmethod read-sql-value (val (type (eql 'generalized-boolean)) database
34                            (db-type (eql :mysql)))
35   (declare (ignore database))
36   (etypecase val
37     (string (if (string= "0" val) nil t))
38     (integer (if (zerop val) nil t))))