Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

lachoy (1663)


I am actually Chris Winters; I am actually living in Pittsburgh, Pennsylvania, USA; I am actually married and have three cats. (Guess what one of them is named?) I am the "OpenInteract" guy, which could be good or bad.

Journal of lachoy (1663)

Monday October 17, 2005
09:28 AM

Another small DBD::Pg issue

[ #27213 ]

I bumped into another DBD::Pg issue posting that last news item, complaining about an unbound placeholder. That's straightforward enough, but in the SQL dumped to the error message there were no placeholders! A closer inspection showed that the dates weren't quoted -- ouch. (SPOPS doesn't use bound placeholders for inserts, instead quoting each value it passes in. I think this was because n years ago DBD::Sybase didn't properly bind TEXT datatypes but I'm not sure.)

Anyway, a little investigation showed that the two-argument quote() method implemented by DBD::Pg does not quote dates properly. The two-argument version takes both the value to be quoted along with the field's datatype ('93' as reported by DBD::Pg for a timestamp field). The one-arg version is fine, though, since it just blindly escapes and quotes whatever you give it.

So the workaround was pretty easy: in SPOPS::DBI::Pg I just had to override the sql_quote() method from SPOPS::SQLInterface to use the one-arg form of DBI->quote() when given a timestamp datatype.

And yes, I created a quick test to show this and posted it to its RT queue like a good open source citizen.

Posted from; read original

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.