[Dbix-class] PostgreSQL's date_part in recent versions of DBIx::Class

Xavier Robin ml-dbixclass at xavier.robin.name
Sun Jan 15 10:40:44 GMT 2012


On Sat, Jan 15, 2012 at 10:04, Peter Rabbitson wrote:
> What you are experiencing is fallout from API misuse. What you told DBIC
> above is "select me a column (literally) named q!date_part('year', created)!.
> Before DBIC would not do additional processing and your weirdly named
> "column" would be ent to the RDBMS as-is, and things appeared to work.
> Everything would stop instantly if you were to say enable quoting of
> identifiers on your storage.
> 
> What you wanted to do is tell DBIC that the above is a literal SQL chunk
> which must be transported to the RDBMS intact. This is done by supplying
> a reference to the chunk in question:
> 
>     select => [ \"date_part('year', created)" ],

Thank you Peter,

I didn't know I was specifically selecting a column, or that a reference
would pass my string intact. Anyway, it works like a charm!

Regards,
Xavier



More information about the DBIx-Class mailing list