On Wed, 2008-12-03 at 16:08 +0100, Maciej Pasternacki wrote:
On 2008-12-03, at 15:46, Phil wrote:
query-dao does not seem to like column names with a dash in them like column-name and I suspect it would have the same problem with spaces.
I know that the preffered for postgresql would be column_name but I though that being able to use the dash would simplify going from db to dao object to html and back, well at least for me.
Is column names with dashes just not supported, a bug or on the wish list?
Everything is supported with :RAW sql-op: (select-dao 'foo (:= (:raw ""foo-bar"") 23)) calls query (SELECT * FROM foo WHERE ("foo-bar" = 23)) (SELECT-DAO is a shortcut for QUERY-DAO, where you supply only the WHERE clause). There doesn't seem to exist any other way now, but it may be possible to add a bit of macro sugar.
Marijn, have you thought of exporting S-SQL::DEF-SQL-OP, so that users can create their own "S-SQL macros"? This may come useful in some cases, like above, or to create reusable parametrized query fragments. With complex queries, macros may come in handy.
Regards, Maciej
Ok maybe I should have been a bit more precise in my description. I was not using the columns names in the query.
Here follows a quick repeatable test:
CREATE TABLE test ( id integer NOT NULL, "some" character varying NOT NULL, "test-dash" character varying ) WITH (OIDS=FALSE); ALTER TABLE test OWNER TO postgres;
insert into test (id,"some","test-dash") values(1, 'some','dash-1');
(defclass test () ((id :col-type string :initarg :id :accessor biographical-id) (some :col-type (or db-null string) :initarg :some :accessor biographical-some) (test-dash :col-type (or db-null string) :initarg :test-dash :accessor biographical-test-dash)) (:metaclass postmodern:dao-class) (:keys id))
(postmodern:query-dao 'test (:select '* :from 'test))
That last bit produces the following error:
No slot named test-dash in class TEST. DAO out of sync with table, or incorrect query used. [Condition of type SIMPLE-ERROR]