Hello,
It appears that setting *escape-sql-names-p* breaks dao objects a bit. If it is t when defclass is called, calling get-dao on that class will result in an error from build-row-reader like "Field field does not exist in table class TABLE-CLASS", even though field does indeed exist. This is because slot-sql-name will return a quoted copy of the field name due to *escape-sql-names-p*.
A fix is to change direct-column-slot's shared-initialize method to use s-sql:make-sql-name rather than to-sql-name; make-sql-name doesn't quote the column name. However, make-sql-name would then need to be exported by s-sql.
A somewhat related issue is that the dao documentation example:
http://common-lisp.net/project/postmodern/postmodern.html#daos
(defclass user () ... )
has problems if *escape-sql-names-p* is not set since user is an sql keyword. I personally would prefer to see *escape-sql-names-p* set as the default, which would fix this issue. Another solution would be to pick a different example class name or to set *escape-sql-names-p*.
Thanks, Gavin Scott gavindscott@gmail.com
Hi Gavin,
Thanks for the report. I have made the following changes:
to-sql-name now takes an optional second argument that overrides *escape-sql-names-p*, and the row-reader builder for DAO classes passes NIL when determining the names of rows.
As for the user table -- I guess you caught me at not testing my own examples ;). I did run it through S-SQL, but not through the database. I have added a (possibly somewhat over-engineered) feature to solve this without turning on escaping for every single identifier: S-SQL now has a table of reserved words, and when *escape-sql-names-p* is :auto (the new default), it will escape those words when it comes across them.
Let me know how this works for you. If there are no problems, I guess I'll do another release (since the get-dao issue is really rather bad).
Cheers, Marijn
That was fast! Your changes work for me. The *escape-sql-names-p* :auto solution looks like the best of both worlds, I wouldn't call it over-engineered ;-)
Thanks, Gavin Scott gavindscott@gmail.com
postmodern-devel@common-lisp.net