Re: Adding SQL types

Marcus Pearce <[email protected]>
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
> What is the proper way to extend CLSQL with additional column types?

CLSQL allows the user to specify the desired (vendor specific) column type
in view class definitions using the :db-type slot option. However, the
conversion from lisp values to SQL values and vice versa (e.g., when
updating the database from the slots of view class instances and vice
versa) is still dependent on the lisp type specified using the :type slot
option.

See http://article.gmane.org/gmane.lisp.clsql.general/177 for an example.

If this doesn't work for you, it is possible to define methods on the
following generics as you suggest:

>   read-sql-value

Used when updating the slot values of view class instances from the
database.

>   database-output-sql-as-type

Used when updating database records from the slot values of view class
instances.

>   database-get-type-specifier

Used to get the SQL column type specifier when constructing a CREATE TABLE
statement (this may be overridden by specifying a string for :db-type in
the view class definition).

> Is it sufficient to define methods on these?

Yes, see the GENERALIZED-BOOLEAN lisp type in sql/oodml.lisp for an
example. If you follow this route and think your extensions would be
generally useful, you might consider submitting them for incorporation
into CLSQL.

Cheers,
Marcus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.