refactored database-output-sql-as-type in a similar fashion to
[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 (eql 'wall-time)) args database
17                                         (db-type (eql :mysql)))
18   (declare (ignore args database))
19   "DATETIME")
20
21 (defmethod database-get-type-specifier ((type (eql 'smallint)) args database
22                                         (db-type (eql :mysql)))
23   (declare (ignore args database))
24   "SMALLINT")
25
26 (defmethod database-get-type-specifier ((type (eql 'mediumint)) args database
27                                         (db-type (eql :mysql)))
28   (declare (ignore args database))
29   "MEDIUMINT")
30
31 (defmethod database-get-type-specifier ((type (eql 'tinyint)) args database
32                                         (db-type (eql :mysql)))
33   (declare (ignore args database))
34   "TINYINT")
35
36 (defmethod read-sql-value (val (type (eql 'boolean)) database
37                            (db-type (eql :mysql)))
38   (declare (ignore database))
39   (etypecase val
40     (string (if (string= "0" val) nil t))
41     (integer (if (zerop val) nil t))))
42
43 (defmethod read-sql-value (val (type (eql 'generalized-boolean)) database
44                            (db-type (eql :mysql)))
45   (declare (ignore database))
46   (etypecase val
47     (string (if (string= "0" val) nil t))
48     (integer (if (zerop val) nil t))))