r50330 - in /trunk/libjifty-dbi-perl: ./ debian/ lib/Jifty/ lib/Jifty/DBI/ lib/Jifty/DBI/Handle/ t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Tue Jan 5 22:32:52 UTC 2010
Author: jawnsy-guest
Date: Tue Jan 5 22:32:44 2010
New Revision: 50330
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50330
Log:
* New upstream release
* Add myself to Uploaders and Copyright
* Update to new DEP5 copyright format
Modified:
trunk/libjifty-dbi-perl/Changes
trunk/libjifty-dbi-perl/META.yml
trunk/libjifty-dbi-perl/SIGNATURE
trunk/libjifty-dbi-perl/debian/changelog
trunk/libjifty-dbi-perl/debian/control
trunk/libjifty-dbi-perl/debian/copyright
trunk/libjifty-dbi-perl/lib/Jifty/DBI.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Collection.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Column.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/Pg.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/SQLite.pm
trunk/libjifty-dbi-perl/lib/Jifty/DBI/Record.pm
trunk/libjifty-dbi-perl/t/12prefetch.t
trunk/libjifty-dbi-perl/t/case_sensitivity.t
Modified: trunk/libjifty-dbi-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/Changes?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/Changes (original)
+++ trunk/libjifty-dbi-perl/Changes Tue Jan 5 22:32:44 2010
@@ -1,4 +1,16 @@
Revision history for Perl extension Jifty::DBI.
+
+0.60 Mon Jan 4 13:02:17 EST 2010
+- Features:
+ * Allow passing of extra parameters to canonicalizers
+ * Add an attribute which controls placeholder use for load_by_cols
+
+- Fixes:
+ * Don't add LOWER() on <= or >= operators, only = and !=
+ * Better case sensitivity tests
+ * Expose quote_value() on Jifty::DBI::Handle
+ * When generating COUT, don't add a DISTINCT unless needed
+ * Fix t/12prefetch.t's assumptions on row ordering
0.59 Wed Nov 18 20:12:57 EST 2009
- Features:
Modified: trunk/libjifty-dbi-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/META.yml?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/META.yml (original)
+++ trunk/libjifty-dbi-perl/META.yml Tue Jan 5 22:32:44 2010
@@ -44,4 +44,4 @@
version: 0
resources:
license: http://dev.perl.org/licenses/
-version: 0.59
+version: 0.60
Modified: trunk/libjifty-dbi-perl/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/SIGNATURE?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/SIGNATURE (original)
+++ trunk/libjifty-dbi-perl/SIGNATURE Tue Jan 5 22:32:44 2010
@@ -15,9 +15,9 @@
Hash: SHA1
SHA1 f29ac6543498d1b0e81f387b7284a039f83e7d29 .gitignore
-SHA1 81b8e2df34131211193bf3b935b5a036dc051ec4 Changes
+SHA1 ebecbc802fdf30c483cb2c9cf0639600e1c4ef43 Changes
SHA1 006b044e48cc925d04f620f317a907d459b2d128 MANIFEST
-SHA1 2f7ef1c4bb35edf899145b1c291924200fcac09f META.yml
+SHA1 d836113207f525431fc0b36592d96c0178e85d70 META.yml
SHA1 48bd6ca8a37ec79b7cae91028d7e9489ad33a03b Makefile.PL
SHA1 ae8407c841f230c353f683bd5c257815aed9b9f0 README
SHA1 82d6ac3f6def48558d09f8b6e3b53ed4194d8c81 ROADMAP
@@ -41,11 +41,11 @@
SHA1 12bf1867955480d47d5171a9e9c6a96fabe0b58f inc/Module/Install/Metadata.pm
SHA1 f7ee667e878bd2faf22ee9358a7b5a2cc8e91ba4 inc/Module/Install/Win32.pm
SHA1 8ed29d6cf217e0977469575d788599cbfb53a5ca inc/Module/Install/WriteAll.pm
-SHA1 2d4ea93c0b624bc5939d882d9c7f0d897fdc63b1 lib/Jifty/DBI.pm
-SHA1 09c42f022a1b2ca5dab645fe9fe6e50ea1fa82b4 lib/Jifty/DBI/Collection.pm
+SHA1 889c457846ee2b8cfbe53b668170043342fcbc7b lib/Jifty/DBI.pm
+SHA1 e406abd0327e7e14d62f46eb8f8684f5e9d86965 lib/Jifty/DBI/Collection.pm
SHA1 639ef9c81f03fb084b312a5f9a6f6a3ff63b36b7 lib/Jifty/DBI/Collection/Union.pm
SHA1 bcba77fd2bacf0475aea1de97f57365c8de92ca6 lib/Jifty/DBI/Collection/Unique.pm
-SHA1 6d59ec1286f3ed887494753d01ed1f4760fd0a9b lib/Jifty/DBI/Column.pm
+SHA1 47caeff7332bb22c9a38e19e15f15f4f11a1f229 lib/Jifty/DBI/Column.pm
SHA1 c21a985a5b799e50f2624e0fa6daee0895313825 lib/Jifty/DBI/Filter.pm
SHA1 e030c3ef5c723ba6dce2e3fc23afecf2a6dfe260 lib/Jifty/DBI/Filter/Boolean.pm
SHA1 d0addaa43cfa8950cb33d42a364a3c3c56a2dd59 lib/Jifty/DBI/Filter/Date.pm
@@ -59,17 +59,17 @@
SHA1 67ffe7188a1f529d7594f4fa3803bcbe15ba6485 lib/Jifty/DBI/Filter/YAML.pm
SHA1 9a6fd17e677321904436fefec4d434e17a4685b1 lib/Jifty/DBI/Filter/base64.pm
SHA1 deb33fa7b35f3542aac3e2d7fb4b5d3070dc3917 lib/Jifty/DBI/Filter/utf8.pm
-SHA1 99a22e6954200e1bf3901cf963b88c2a830e460f lib/Jifty/DBI/Handle.pm
+SHA1 3e42dd9a4a0106219d15ac32c377539aa50ea4c4 lib/Jifty/DBI/Handle.pm
SHA1 bcc7c456e1c4d0dddd5564f03c8bb03a6c7e261f lib/Jifty/DBI/Handle/Informix.pm
SHA1 338116a45f8eb6bfca5e76e8d3be78fb61fffe81 lib/Jifty/DBI/Handle/ODBC.pm
SHA1 960fd0b63f3de11924c5d47a3c0c6d1db105ed5b lib/Jifty/DBI/Handle/Oracle.pm
-SHA1 23eeff073884c8951e004be4308ca946a1d5e205 lib/Jifty/DBI/Handle/Pg.pm
-SHA1 1e850abb12a1d970eae373f452219c123be350e6 lib/Jifty/DBI/Handle/SQLite.pm
+SHA1 d1757e2c992ead86f70f0dfc9c659387dc9600cf lib/Jifty/DBI/Handle/Pg.pm
+SHA1 2f4c08340712bd21679282ebd669ce7b99d6d646 lib/Jifty/DBI/Handle/SQLite.pm
SHA1 bba2314c20fcc3ef71cc69090f1cd6bd515cd9b4 lib/Jifty/DBI/Handle/Sybase.pm
SHA1 cf80896a175702a157770f64ae469430678c3357 lib/Jifty/DBI/Handle/mysql.pm
SHA1 f2cc4fcce79c9a88a023d4e6bd96c2089eef1ced lib/Jifty/DBI/Handle/mysqlPP.pm
SHA1 45d653e3a223599b50850010826bd835b80368d7 lib/Jifty/DBI/HasFilters.pm
-SHA1 24de085d41bfa49b1a6588311e675cff0615c8f0 lib/Jifty/DBI/Record.pm
+SHA1 78a2d14d076f088b66433ab3be2f45c8b0474c34 lib/Jifty/DBI/Record.pm
SHA1 663978b31373520d1e2deec87e957d1dbfd1347c lib/Jifty/DBI/Record/Cachable.pm
SHA1 1aac77960c508d3b2e5188e15825ad5b04391d76 lib/Jifty/DBI/Record/Memcached.pm
SHA1 53834b3315a509ba33a8647681f472d3ae7b0557 lib/Jifty/DBI/Record/Plugin.pm
@@ -100,7 +100,7 @@
SHA1 bb91f506a251d7b27d2fcd29c482a345318ef04f t/06filter_yaml.t
SHA1 64c3722f5b34feafc87113257079721c174f3f96 t/10schema.t
SHA1 0f4655f0a4e558ac31df7b7fdf17c9b110f934da t/11schema_records.t
-SHA1 22a083137927a8635b02931e40f80c60220ec3a7 t/12prefetch.t
+SHA1 164ebb7144e978617c81306f5017bdcbcf41b801 t/12prefetch.t
SHA1 2389b47958bd6f92a561ca893d7bfab166ced127 t/13collection.t
SHA1 41b7fbaf031d103a4f2066f177cc3bee84ab0458 t/14handle-pg.t
SHA1 4f41229caa246bf6ebb369010deb0c1eb8809666 t/15types.t
@@ -109,16 +109,16 @@
SHA1 cc7d6dd9889837143074729d30030ddabcfa6b9e t/18triggers.t
SHA1 54b7727b49111162703581d13dd47dfe276fbe9a t/19reference.t
SHA1 72a16ddfc2642564023448450f3475ae5abf6d86 t/20overload.t
-SHA1 5b3f8373687f89ccf3faf2dfbda9663137a8c078 t/case_sensitivity.t
+SHA1 5e1158a9340410d46ffad19f381982159dccc924 t/case_sensitivity.t
SHA1 1dd9675b0a9a59fdcd300f5d92297f0ecf4f03e4 t/metadata.t
SHA1 59c44900b1cb957d262f96363ceff21b46e0d598 t/pod-coverage.t
SHA1 e9c6a5881fc60173fbc8d479c1afd2ce3b43bef1 t/pod.t
SHA1 62742c946808f35bcc8b2777e975c1ce068a0a71 t/testmodels.pl
SHA1 653c2f961d8b4f195e5391cd261f37815068e8d5 t/utils.pl
-----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.7 (Darwin)
+Version: GnuPG v2.0.14 (GNU/Linux)
-iD8DBQFLBJv7sxfQtHhyRPoRAog4AKCIv7JYxk/gyfUsKD1I6AwLS1tSfwCfeY18
-jZQ6G3H6abFEj8XNr5+p6TQ=
-=ao3T
+iEYEARECAAYFAktCLRQACgkQMflWJZZAbqAAOwCeOxm56OcXyvFYKXRdNUHxJNHF
+VUEAoLquqWn/1ANIGQffysa0WwKfOStP
+=AGva
-----END PGP SIGNATURE-----
Modified: trunk/libjifty-dbi-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/debian/changelog?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/debian/changelog (original)
+++ trunk/libjifty-dbi-perl/debian/changelog Tue Jan 5 22:32:44 2010
@@ -1,3 +1,11 @@
+libjifty-dbi-perl (0.60-1) UNRELEASED; urgency=low
+
+ * New upstream release
+ * Add myself to Uploaders and Copyright
+ * Update to new DEP5 copyright format
+
+ -- Jonathan Yu <jawnsy at cpan.org> Tue, 05 Jan 2010 17:29:39 -0500
+
libjifty-dbi-perl (0.59-1) unstable; urgency=low
[ gregor herrmann ]
Modified: trunk/libjifty-dbi-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/debian/control?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/debian/control (original)
+++ trunk/libjifty-dbi-perl/debian/control Tue Jan 5 22:32:44 2010
@@ -32,7 +32,8 @@
perl (>= 5.10) | libversion-perl,
libyaml-syck-perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: AGOSTINI Yves <agostini at univ-metz.fr>
+Uploaders: AGOSTINI Yves <agostini at univ-metz.fr>,
+ Jonathan Yu <jawnsy at cpan.org>
Standards-Version: 3.8.3
Homepage: http://search.cpan.org/dist/Jifty-DBI/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libjifty-dbi-perl/
Modified: trunk/libjifty-dbi-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/debian/copyright?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/debian/copyright (original)
+++ trunk/libjifty-dbi-perl/debian/copyright Tue Jan 5 22:32:44 2010
@@ -1,34 +1,36 @@
-Format-Specification:
- http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: Jesse Vincent <jesse at bestpractical.com>, Alex Vandiver
- <alexmv at bestpractical.com>, Ruslan Zakirov <ruslan.zakirov at gmail.com>
-Upstream-Source: http://search.cpan.org/dist/Jifty-DBI/
-Upstream-Name: Jifty-DBI
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59
+Maintainer: Alex Vandiver <alexmv at bestpractical.com>
+Source: http://search.cpan.org/dist/Jifty-DBI/
+Name: Jifty-DBI
Files: *
-Copyright: 2005-2009 Best Practical Solutions, LLC.
-License-Alias: Perl
-License: Artistic | GPL-1+
+Copyright: 2005-2009, Best Practical Solutions, LLC.
+License: Artistic or GPL-1+
-Files: inc/*
-Copyright: Copyright 2002 - 2009 by Brian Ingerson, Audrey Tang and Adam Kennedy.
-License-Alias: Perl
-License: Artistic | GPL-1+
+Files: inc/Module/*
+Copyright: 2002-2009, Adam Kennedy <adamk at cpan.org>
+ 2002-2009, Audrey Tang <autrijus at autrijus.org>
+ 2002-2009, Brian Ingerson <ingy at cpan.org>
+License: Artistic or GPL-1+
Files: debian/*
-Copyright: 2009, AGOSTINI Yves <agostini at univ-metz.fr>
-License: Artistic | GPL-1+
+Copyright: 2010, Jonathan Yu <jawnsy at cpan.org>
+ 2009, AGOSTINI Yves <agostini at univ-metz.fr>
+License: Artistic or GPL-1+
License: Artistic
- This program is free software; you can redistribute it and/or modify
- it under the terms of the Artistic License, which comes with Perl.
- On Debian GNU/Linux systems, the complete text of the Artistic License
- can be found in `/usr/share/common-licenses/Artistic'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian GNU/Linux systems, the complete text of the Artistic License
+ can be found in `/usr/share/common-licenses/Artistic'
License: GPL-1+
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
- On Debian GNU/Linux systems, the complete text of the GNU General
- Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian GNU/Linux systems, the complete text of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL'
+
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI.pm Tue Jan 5 22:32:44 2010
@@ -2,7 +2,7 @@
use warnings;
use strict;
-$Jifty::DBI::VERSION = '0.59';
+$Jifty::DBI::VERSION = '0.60';
=head1 NAME
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Collection.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Collection.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Collection.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Collection.pm Tue Jan 5 22:32:44 2010
@@ -802,7 +802,7 @@
}
# DISTINCT query only required for multi-table selects
- if ( $self->_is_joined ) {
+ if ( $self->distinct_required or $self->prefetch_related ) {
$query_string = $self->_handle->distinct_count( \$query_string );
} else {
$query_string = "SELECT count(main.id) FROM " . $query_string;
@@ -1265,15 +1265,15 @@
if ( $args{'quote_value'} && $args{'operator'} !~ /IS/i ) {
if ( $value_ref eq 'ARRAY' ) {
- map { $_ = $self->_quote_value($_) } @{ $args{'value'} };
+ map { $_ = $self->_handle->quote_value($_) } @{ $args{'value'} };
} else {
- $args{'value'} = $self->_quote_value( $args{'value'} );
+ $args{'value'} = $self->_handle->quote_value( $args{'value'} );
}
}
}
if ( $args{'escape'} ) {
- $args{'escape'} = 'ESCAPE ' . $self->_quote_value( $args{escape} );
+ $args{'escape'} = 'ESCAPE ' . $self->_handle->quote_value( $args{escape} );
}
# If we're trying to get a leftjoin restriction, lets set
@@ -1482,22 +1482,10 @@
$self->{$type} = $value;
}
-# quote the search value
+# stub for back-compat
sub _quote_value {
my $self = shift;
- my ($value) = @_;
-
- my $tmp = $self->_handle->dbh->quote($value);
-
- # Accomodate DBI drivers that don't understand UTF8
- if ( $] >= 5.007 ) {
- require Encode;
- if ( Encode::is_utf8($tmp) ) {
- Encode::_utf8_on($tmp);
- }
- }
- return $tmp;
-
+ return $self->_handle->quote_value(@_);
}
=head2 order_by_cols DEPRECATED
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Column.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Column.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Column.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Column.pm Tue Jan 5 22:32:44 2010
@@ -42,6 +42,7 @@
valid_values
available_values
autocompleted
+ no_placeholder
/;
# compat: this should probably never exist and be deprecated
@@ -138,19 +139,25 @@
=over
-=item container
-
-=item label hints render_as
-
-=item display_length
-
-=item valid_values
-
-=item available_values
-
-=item autocompleted
-
-=item documentation
+=item container
+
+=item label hints render_as
+
+=item display_length
+
+=item valid_values
+
+=item available_values
+
+=item autocompleted
+
+=item documentation
+
+=item no_placeholder
+
+Setting this to a true value causes L<Jifty::DBI::record/load_by_cols>
+to not use a placeholder when loading the column. This can allow the
+database to come up with better query plans in some cases.
=back
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle.pm Tue Jan 5 22:32:44 2010
@@ -716,7 +716,7 @@
return $value ne ''
&& $value ne "''"
- && ( $operator !~ /IS/ && $value !~ /^null$/i )
+ && ( $operator =~ /^(?:(?:NOT )?LIKE|!?=|IN)$/i )
# don't downcase integer values
&& $value !~ /^['"]?\d+['"]?$/;
@@ -737,6 +737,29 @@
}
}
return ( $column, $operator, $value );
+}
+
+=head2 quote_value VALUE
+
+Calls the database's L<DBD/quote> method and returns the result.
+Additionally, turns on perl's utf8 flag if the returned content is
+UTF8.
+
+=cut
+
+sub quote_value {
+ my $self = shift;
+ my ($value) = @_;
+ my $tmp = $self->dbh->quote($value);
+
+ # Accomodate DBI drivers that don't understand UTF8
+ if ( $] >= 5.007 ) {
+ require Encode;
+ if ( Encode::is_utf8($tmp) ) {
+ Encode::_utf8_on($tmp);
+ }
+ }
+ return $tmp;
}
=head2 begin_transaction
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/Pg.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/Pg.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/Pg.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/Pg.pm Tue Jan 5 22:32:44 2010
@@ -173,13 +173,11 @@
my $value = shift;
if ( $self->_case_insensitivity_valid( $column, $operator, $value ) ) {
- if ( $operator =~ /(?:LIKE|=|IN)/i ) {
- $column = "LOWER($column)";
- if ( $operator =~ /^(IN|=)$/i and ref($value) eq 'ARRAY' ) {
- $value = [ map {"LOWER($_)"} @$value ];
- } else {
- $value = "LOWER($value)";
- }
+ $column = "LOWER($column)";
+ if ( $operator =~ /^(IN|=)$/i and ref($value) eq 'ARRAY' ) {
+ $value = [ map {"LOWER($_)"} @$value ];
+ } else {
+ $value = "LOWER($value)";
}
}
return ( $column, $operator, $value );
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/SQLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/SQLite.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/SQLite.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Handle/SQLite.pm Tue Jan 5 22:32:44 2010
@@ -95,6 +95,10 @@
my $column = shift;
my $operator = shift;
my $value = shift;
+
+ return ($column, $operator, $value)
+ unless $self->_case_insensitivity_valid( $column, $operator, $value );
+
return("$column COLLATE NOCASE", $operator, $value);
}
Modified: trunk/libjifty-dbi-perl/lib/Jifty/DBI/Record.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/lib/Jifty/DBI/Record.pm?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/lib/Jifty/DBI/Record.pm (original)
+++ trunk/libjifty-dbi-perl/lib/Jifty/DBI/Record.pm Tue Jan 5 22:32:44 2010
@@ -1140,8 +1140,13 @@
}
}
- push @phrases, "$key $op $function";
- push @bind, $value;
+ if ($column_obj and $column_obj->no_placeholder and $function eq "?") {
+ push @phrases, "$key $op ".$self->_handle->quote_value($value);
+ } else {
+ push @phrases, "$key $op $function";
+ push @bind, $value;
+ }
+
} elsif ( !defined $hash{$key} ) {
push @phrases, "$key IS NULL";
} else {
@@ -1700,12 +1705,14 @@
my %args = (
column => undef,
value => undef,
+ extra => [],
@_
);
my ( $ret, $value_ref ) = $self->_run_callback(
- name => "canonicalize_" . $args{'column'},
- args => $args{'value'},
+ name => "canonicalize_" . $args{'column'},
+ args => $args{'value'},
+ extra => $args{'extra'},
short_circuit => 0,
);
return unless defined $ret;
@@ -1753,7 +1760,11 @@
my $attr = $args{'value'};
my ( $ret, $results )
- = $self->_run_callback( name => "validate_" . $key, args => $attr, extra => $args{'extra'} );
+ = $self->_run_callback(
+ name => "validate_" . $key,
+ args => $attr,
+ extra => $args{'extra'},
+ );
if ( defined $ret ) {
return ( 1, 'Validation ok' );
Modified: trunk/libjifty-dbi-perl/t/12prefetch.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/t/12prefetch.t?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/t/12prefetch.t (original)
+++ trunk/libjifty-dbi-perl/t/12prefetch.t Tue Jan 5 22:32:44 2010
@@ -7,7 +7,7 @@
BEGIN { require "t/utils.pl" }
our (@available_drivers);
-use constant TESTS_PER_DRIVER => 58;
+use constant TESTS_PER_DRIVER => 59;
my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
@@ -95,12 +95,14 @@
column2 => 'employee'
);
$collection->prefetch( $phones_alias => 'phones' );
+ $collection->order_by( column => 'id' );
is( $collection->count, 2 );
is( scalar( $handle->sql_statement_log ),
1, "count is one statement" );
$handle->clear_sql_statement_log;
my $user = $collection->next;
+ is( $user->name, 'RUZ' );
is( $user->id, 1, "got our user" );
my $phones = $user->phones;
is( $phones->first->id, 1 );
Modified: trunk/libjifty-dbi-perl/t/case_sensitivity.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-dbi-perl/t/case_sensitivity.t?rev=50330&op=diff
==============================================================================
--- trunk/libjifty-dbi-perl/t/case_sensitivity.t (original)
+++ trunk/libjifty-dbi-perl/t/case_sensitivity.t Tue Jan 5 22:32:44 2010
@@ -6,63 +6,126 @@
BEGIN { require "t/utils.pl" }
our (@available_drivers);
-use constant TESTS_PER_DRIVER => 9;
+use constant TESTS_PER_DRIVER => 139;
my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
use DateTime ();
-foreach my $d ( @available_drivers ) {
+foreach my $d (@available_drivers) {
SKIP: {
- unless( has_schema( 'TestApp::User', $d ) ) {
- skip "No schema for '$d' driver", TESTS_PER_DRIVER;
- }
- unless( should_test( $d ) ) {
- skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
- }
- diag("start testing with '$d' handle") if $ENV{TEST_VERBOSE};
+ unless ( has_schema( 'TestApp::User', $d ) ) {
+ skip "No schema for '$d' driver", TESTS_PER_DRIVER;
+ }
+ unless ( should_test($d) ) {
+ skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
+ }
+ diag("start testing with '$d' handle") if $ENV{TEST_VERBOSE};
- my $handle = get_handle( $d );
- connect_handle( $handle );
- isa_ok($handle->dbh, 'DBI::db');
+ my $handle = get_handle($d);
+ connect_handle($handle);
+ isa_ok( $handle->dbh, 'DBI::db' );
- {my $ret = init_schema( 'TestApp::User', $handle );
- isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back" );}
-
- my $rec = TestApp::User->new( handle => $handle );
- isa_ok($rec, 'Jifty::DBI::Record');
-
- my ($id) = $rec->create( name => 'Foobar', interests => 'Slacking' );
- ok($id, "Successfuly created ticket");
-
- $rec->load_by_cols( name => 'foobar');
- TODO: {
- local $TODO = "How do we force mysql to be case sensitive?" if ( $d eq 'mysql' || $d eq 'mysqlPP' );
- is($rec->id, undef);
+ {
+ my $ret = init_schema( 'TestApp::User', $handle );
+ isa_ok( $ret, 'DBI::st',
+ "Inserted the schema. got a statement handle back" );
}
- $rec->load_by_cols( name => { value => 'foobar', case_sensitive => 0, operator => '=' });
- is($rec->id, $id);
+ my $rec = TestApp::User->new( handle => $handle );
+ isa_ok( $rec, 'Jifty::DBI::Record' );
- $rec->load_by_cols( name => 'Foobar');
- is($rec->id, $id);
+ my ($id) = $rec->create( name => 'Foobar', interests => 'Slacking' );
+ ok( $id, "Successfuly created ticket" );
- $rec->load_by_cols( interests => 'slacking');
- is($rec->id, $id);;
+ $rec->load_by_cols( name => 'foobar' );
+TODO: {
+ local $TODO = "How do we force mysql to be case sensitive?"
+ if ( $d eq 'mysql' || $d eq 'mysqlPP' );
+ is( $rec->id, undef );
+ }
- $rec->load_by_cols( interests => 'Slacking');
- is($rec->id, $id);;
+ $rec->load_by_cols( name =>
+ { value => 'foobar', case_sensitive => 0, operator => '=' } );
+ is( $rec->id, $id );
- cleanup_schema( 'TestApp', $handle );
- disconnect_handle( $handle );
+ $rec->load_by_cols( name => 'Foobar' );
+ is( $rec->id, $id );
+
+ $rec->load_by_cols( interests => 'slacking' );
+ is( $rec->id, $id );
+
+ $rec->load_by_cols( interests => 'Slacking' );
+ is( $rec->id, $id );
+
+# IN
+# IS
+# IS NOT
+
+ ### Numbers
+ threeway_same($handle, id => $_, 42) for qw/= != < > <= >=/;
+ threeway_same($handle, id => $_, 42) for ("LIKE", "NOT LIKE", "MATCHES", "STARTS_WITH", "ENDS_WITH");
+ threeway_same($handle, id => $_ => [ 42, 17 ]) for qw/= IN/;
+ threeway_same($handle, id => $_ => 'NULL') for ("IS", "IS NOT");
+ threeway_same($handle, id => $_ => 'null') for ("IS", "IS NOT");
+
+ ## Strings
+ threeway_same($handle, name => $_, "bob") for qw/< > <= >=/;
+ threeway_same($handle, name => $_, 17) for ("=", "!=", "LIKE", "NOT LIKE");
+ threeway_different($handle, name => $_, 17) for ("MATCHES", "STARTS_WITH", "ENDS_WITH");
+ threeway_different($handle, name => $_, "bob") for ("=", "!=", "LIKE", "NOT LIKE", "MATCHES", "STARTS_WITH", "ENDS_WITH");
+ threeway_different($handle, name => $_, "null") for ("=", "!=", "LIKE", "NOT LIKE", "MATCHES", "STARTS_WITH", "ENDS_WITH");
+ threeway_different($handle, name => $_ => [ "bob", "alice" ]) for qw/= IN/;
+ threeway_same($handle, name => $_ => 'NULL') for ("IS", "IS NOT");
+ threeway_same($handle, name => $_ => 'null') for ("IS", "IS NOT");
+
+ ## Other
+ threeway_same($handle, created => $_, 42) for qw/= != < > <= >=/;
+ threeway_same($handle, created => $_, 42) for ("LIKE", "NOT LIKE", "MATCHES", "STARTS_WITH", "ENDS_WITH");
+ threeway_same($handle, created => $_ => [ 42, 17 ]) for qw/= IN/;
+ threeway_same($handle, created => $_ => 'NULL') for ("IS", "IS NOT");
+ threeway_same($handle, created => $_ => 'null') for ("IS", "IS NOT");
+
+ cleanup_schema( 'TestApp', $handle );
+ disconnect_handle($handle);
}
+}
+
+sub threeway_same {
+ my ($default, $insensitive, $sensitive) = threeway_test(@_);
+ shift @_;
+ is( $default, $insensitive, "Default and insensitive queries are the same (@_)");
+ is( $sensitive, $insensitive, "Sensitive and insensitive queries are the same (@_)");
+}
+
+sub threeway_different {
+ my ($default, $insensitive, $sensitive) = threeway_test(@_);
+ my $handle = shift @_;
+ is( $default, $sensitive, "Default and insensitive queries are the same (@_)");
+TODO: {
+ local $TODO = "How do we force mysql to be case sensitive?"
+ if $handle =~ /mysql/;
+ isnt( $sensitive, $insensitive, "Sensitive and insensitive queries are not the same (@_)");
+ }
+}
+
+sub threeway_test {
+ my ($handle, $column, $op, $value) = @_;
+ my $default = TestApp::UserCollection->new( handle => $handle );
+ $default->limit( column => $column, value => $value, operator => $op );
+
+ my $insensitive = TestApp::UserCollection->new( handle => $handle );
+ $insensitive->limit( column => $column, value => $value, operator => $op, case_sensitive => 0 );
+
+ my $sensitive = TestApp::UserCollection->new( handle => $handle );
+ $sensitive->limit( column => $column, value => $value, operator => $op, case_sensitive => 1 );
+
+ return map {$_->build_select_query} ($default, $insensitive, $sensitive);
}
package TestApp::User;
use base qw/Jifty::DBI::Record/;
-
-1;
sub schema_sqlite {
@@ -70,7 +133,8 @@
CREATE table users (
id integer primary key,
name varchar,
- interests varchar
+ interests varchar,
+ created date
)
EOF
@@ -82,7 +146,8 @@
CREATE TEMPORARY table users (
id integer auto_increment primary key,
name varchar(255),
- interests varchar(255)
+ interests varchar(255),
+ created date
)
EOF
@@ -94,7 +159,8 @@
CREATE TEMPORARY table users (
id serial primary key,
name varchar,
- interests varchar
+ interests varchar,
+ created date
)
EOF
@@ -105,8 +171,11 @@
use Jifty::DBI::Record schema {
column name => type is 'varchar', label is 'Name', is case_sensitive;
column interests => type is 'varchar';
+ column created => type is 'date';
};
+package TestApp::UserCollection;
+use base qw/Jifty::DBI::Collection/;
1;
More information about the Pkg-perl-cvs-commits
mailing list