I am having problem putting together a DBIx::Class query that uses a mysql-function in the where-clause.
Here is my resultset:
The query I want to (re-)construct is select id, msg, box from queue where is_lock_free(box) order by id limit 1package MyDB::Schema::Result::Queue; use strict; use base qw/DBIx::Class::Core/; __PACKAGE__->table('queue'); __PACKAGE__->add_columns( id => { is_auto_increment => 1}, qw/ msg box /); __PACKAGE__->set_primary_key('id'); 1;
The best I can get at the moment is
Which produces SELECT me.id, me.msg, me.box FROM queue me WHERE ( is_free_lock(me.box) ) ORDER BY id LIMIT 1 which actually works but of course is obtained by cheating because I supplied the me.box argument to is_lock_free by hand...my $rs = $schema->resultset('Queue'); my $q = $rs->search ({ -bool => "is_free_lock(me.box)" }, { order_by = +> 'id', rows => 1 })->single;
How can I do this without cheating?
Many thanks!
In reply to DBIx::Class query question by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |