0

I want to convert this mysql/select query with function to DBIx::Class but I can't construct it the right way.

Mysql/query with function:

mysql> select * from sold_products 
       where date_sub(curdate(), interval 100 day) <= date;

Result query on DBIC_TRACE:

SELECT me.fk_product, me.fk_customer, me.amount, me.quantity, me.date, me.pk_sold 
FROM sold_products me WHERE ( date > date_sub(curdate(), interval 100 day ):

P.S DBIx is already upgraded.

thanks, lupin

a'r
  • 35,921
  • 7
  • 66
  • 67
lupin
  • 1
  • 4
    Am I missing something here? It looks to me as though the two SQL statements are functionally identical. – Dave Cross Jan 27 '11 at 09:58
  • is the DBIC_TRACE what you are seeing or what you want to see? they seem ok, if there are columns missing in your output, then check you have defined them all in your DBIx::Class::Result::SoldProducts class, and that there is no lazy population of columns going on – plusplus Jan 27 '11 at 12:16
  • 1
    @davorg, you're missing the difference between `x <= 5` and `5 > x`. Those are not (quite) equivalent. – cjm Jan 27 '11 at 19:35

1 Answers1

0

In your DBIx query you want the hash key to be '>=', not '>'. date => {'>=', whatever_here }? Did you try that already?

rndapology
  • 142
  • 6