[REBOL] Re: Mysql-protocol Date issue
From: dockimbel:free at: 15-Aug-2003 3:56
Hi Tim,
Tim Johnson wrote:
[...]
> Here's the problem:
> My current version (0.9.9) of DocKimbel's mysql-protocol throws
> an exception if '0000-00-00' is found.
The driver tries to convert it to a date! value, but it's an invalid date for
REBOL :
>> 0000-00-00
** Syntax Error: Invalid date -- 0000-00-00
** Near: (line 1) 0000-00-00
> Does anyone know if there is a fix for this, a configuration switch or
> whatever? I'd like to avoid hacking Nenad's code to get around this.
No need to hack ;-), here's a workaround :
- Just after opening the port, add this line :
change-type-handler your-db-port 'date [to string!]
- Now, for this db port only, all MySQL date types will remain as string! (It's
then up to you to decide if and how you want to convert these values)
- You can also provide a little more sophisticate handler for 'date :
to-date-except-zero: func [value][
attempt [value: to date! value]
value
]
change-type-handler your-db-port 'date [to-date-except-zero]
(This one will convert to date! only if possible)
> Also, I note that the URL for the protocol
> (http://rebol.dhs.org/mysql/) is not reachable at this time.
> Does anyone if he has relocated?
http://rebol.softinnov.org/mysql/
HTH,
-DocKimbel