[Dbix-class] where as a attribut with scalar reference
Frank Wiegand
frank.wiegand at gmail.com
Thu Dec 21 11:52:14 GMT 2006
Hi,
is C< where > supposed to work with a scalar (or list) reference? If yes,
then it's broken.
Note: The following code is for MySQL.
CREATE TABLE confirmation (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user INT UNSIGNED,
FOREIGN KEY (user) REFERENCES user (id),
confirm_id VARCHAR(40),
created TIMESTAMP,
INDEX(confirm_id)
);
I would like to query all confirmations that are outdated (older than
2 days), in MySQL this could be
SELECT id FROM confirmation WHERE DATEDIFF( NOW(), created ) > 2;
With DBIC, this works fine if I set some conditions as first param to
C< search >:
my $outdated =3D $c->model('DBIC::Confirmation')->search(
$condition,
{ where =3D> \'DATEDIFF( NOW(), created ) > 2' }
);
But if C< $condition > is undef, then DBIC complains:
my $outdated =3D $c->model('DBIC::Confirmation')->search(
undef,
{ where =3D> \'DATEDIFF( NOW(), created ) > 2' }
);
Modification of a read-only value attempted at
/usr/local/share/perl/5.8.8/DBIx/Class/Storage/DBI.pm line 812.
A simpler testcase for the DBIC testsuite is attached.
Thanks, Frank
-------------- next part --------------
A non-text attachment was scrubbed...
Name: where.t
Type: text/troff
Size: 799 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20061221/59=
cfe231/where.bin
More information about the Dbix-class
mailing list