fukamachi / integral

[OBSOLETE] Use Mito instead.
https://github.com/fukamachi/mito
BSD 3-Clause "New" or "Revised" License
54 stars 3 forks source link

Table names not escaped/converted #33

Closed lucashpandolfo closed 9 years ago

lucashpandolfo commented 9 years ago

This works

(integral:connect-toplevel :sqlite3
                           :database-name "/tmp/mydb.db")

(defclass tweet ()
  ((id :type integer
       :primary-key t
       :auto-increment t
       :reader tweet-id)
   (status :type text
           :initarg :status
           :accessor tweet-status)
   (user :type (varchar 32)
         :initarg :user
         :accessor tweet-user))
  (:metaclass integral:<dao-table-class>))

(integral:ensure-table-exists 'tweet)

(let ((tw (make-instance 'tweet
                         :status "Good morning, world."
                         :user "nitro_idiot")))
  (integral:save-dao tw))

This does not work

(defclass lispy-name-tweet ()
  ((id :type integer
       :primary-key t
       :auto-increment t
       :reader tweet-id)
   (status :type text
           :initarg :status
           :accessor tweet-status)
   (user :type (varchar 32)
         :initarg :user
         :accessor tweet-user))
  (:metaclass integral:<dao-table-class>))

(integral:ensure-table-exists 'lispy-name-tweet)

(let ((tw (make-instance 'lispy-name-tweet
                         :status "Good morning, world."
                         :user "nitro_idiot")))
  (integral:save-dao tw))

sqlite => DB Error: near "-": syntax error (Code: ERROR)
   [Condition of type DBI.ERROR:<DBI-PROGRAMMING-ERROR>]

mysql => DB Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-name-tweet ORDER BY id DESC LIMIT 1' at line 1 (Code: 1064)
   [Condition of type DBI.ERROR:<DBI-PROGRAMMING-ERROR>]

The generated query is:

sqlite => "SELECT id AS last_insert_id FROM lispy-name-tweet ORDER BY id LIMIT 1" mysql => "SELECT id AS last_insert_id FROM lispy-name-tweet ORDER BY id DESC LIMIT 1"