Re: MySQL and 0000-00-00 dates

Kevin Rosenberg <kevin-HJRc7zDS/[email protected]>
Newsgroups gmane.lisp.clsql.general
Message-ID <[email protected]>
I wonder if the best fix for this would be to look for 0000-00-00 as a  
special case and then
convert than to NULL.

Kevin

On Dec 4, 2008, at 1:57 PM, Thom Goodsell wrote:

> Sorry if this has been addressed, I did my best to search the
> archives, but if there's an easy way to search them, I've missed it.
>
> Clsql blows up when reading 0000-00-00 dates out of a MySQL database.
> It seems to do so because it's not a valid date (which is a pretty
> reasonable thing for it to do), but this is a common MySQL idiom, and
> I would expect friendlier behavior from clsql. Is there a best
> practice for getting clsql to behave differently in the face of these
> dates?
>
> Thanks,
> Thom
>
>
> FURTHER DETAILS
>
> The error I see is this:
>
> Bad component: NIL
>    [Condition of type CLSQL-SYS::ISO-8601-SYNTAX-ERROR]
>
> Which appears to be caused by handling this error (from time.lisp: 
> 1341):
>
>           (unless (< 0 year)
>             (error 'iso-8601-syntax-error
>                    :bad-component '(year . 0)))
>
> This is using def-view-class. If I set the slot type to be (or
> clsql:date nil), in the hope that the bad date would be recognized as
> a null value, I get this error:
>
> The value 0000-00-00 can not be used to set the value of the slot
> BIRTHDATE in #<PROFILE #<error printing PROFILE #x3000432F0DFD>,
> because it is not of type (OR  NULL CLSQL-SYS:DATE).
>    [Condition of type CCL::BAD-SLOT-TYPE]
>
>
> _______________________________________________
> CLSQL mailing list
> [email protected]
> http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
>
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.