On 2013-04-24 19:40, stephenmoy wrote:
Sorry Alex, I left out the '=>' when I copied the query.
I tried the examples in the SQL::Abstract docs as well, but still in each
case, any multiple 'LOWER' functions gave an error.
I.E.: these work fine:
A) my @students = $schema->resultset( 'GraduateStudent' )->search(
-or => [ 'LOWER( me.email )' => $srch,
'me.uid' => $srch,
]
);
B) my @students = $schema->resultset( 'GraduateStudent' )->search({ -or =>
[
\[ 'LOWER(email) = ?', [ plain_value =>
$srch ] ],
uid => $srch,
]});
these don't work:
C) my @students = $schema->resultset( 'GraduateStudent' )->search(
-or => [ 'LOWER( me.email )' => $srch,
'LOWER( me.uid )' => $srch,
]
);
D) my @students = $schema->resultset( 'GraduateStudent' )->search({ -or =>
[
\[ 'LOWER(email) = ?', [ plain_value =>
$srch ] ],
\[ 'LOWER(uid) = ?', [ plain_value => $srch
] ],
]});
I wonder if this is a DBIC issue or an Ingres ODBC issue.
Best,
Stephen
Looks like you need to manually define the bind datatype, see [1]:
my @students = $schema->resultset( 'GraduateStudent' )->search({
-or => [
# the long form
\[ 'LOWER(email) = ?', [ { sqlt_datatype => 'string' }, $srch ] ],
# the shortcut
\[ 'LOWER(uid) = ?', [ \'integer' => $srch ] ],
]});
Note that the upcoming DBIx::Class version has both simplified syntax for bind
values as well as (hopefully) better docs [2].
[1] https://metacpan.org/module/DBIx::Class::ResultSet#DBIC-BIND-VALUES
[2]
https://metacpan.org/module/RIBASUSHI/DBIx-Class-0.08249_04/lib/DBIx/Class/ResultSet.pm#DBIC-BIND-VALUES
--
View this message in context:
http://dbix-class.35028.n2.nabble.com/Best-practice-for-case-insensitive-searches-tp5963279p7578139.html
Sent from the DBIx-Class mailing list archive at Nabble.com.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]