[Dbix-class] Limitations in building WHERE-Clauses?

Sven Eppler sven at sveneppler.de
Tue Jun 12 08:08:01 GMT 2007


Hello!

I'm realy a big fan of DBIx::Class. It makes life so much easier.

But slowly it seems to me, that it will mak life easier only in the first
look. My special problem looks in SQL just as simple as this:

--- SQL ---
SELECT field1 FROM table
WHERE DATE(field2) > DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK)
--- /SQL ---

Well, as you see, it's a quite easy (My)SQL-Statement to retrieve
everything thats one week old. I know, i could workaround the problem by
not defining field2 as a Datetime-Field but have a separated DATE and a
TIME field. But actually suits the DATETIME field the problem much better.
So if i wanted to compare the Datetime-Field against a date i need to
"cast" the Datetime-Field to a date field with DATE().

But currently i don't see any possibility to accomplish this in
DBIx::Class? Or am i just overlooking something?

The other thing ist the right side of the WHERE-Clause. The desired
function calls would probably be recreateable in DBIx::Class. But i hope
you all agree with me that even in this simple case (no ANDin or ORing)
the Syntax-Overhead is really going somewhere i don't want it do go.

So i asked for myself if there is a way i can run "raw SQL" through
DBIx::Class or can't i benefit in any way from DBIx::Class in such
situations and have to get me myself a DB-Handle from DBI and run my SQL
the way it was done in the old days?

Thanks in advance,
Sven






More information about the Dbix-class mailing list