@@ -1,5 +1,32 @@
Revision history for DBIx-Class-Helpers
+2.023007 2014-09-16 19:48:34-05:00 America/Chicago
+ - Fix ::Helper::ResultSet::DateMethods1 for Oracle (thanks Alexander Hartmaier!)
+ - Fix yet another issue with ->copy and proxied ResultSet methods (thanks again
+ moltar!)
+
+2.023006 2014-09-03 17:44:34-05:00 America/Chicago
+ - Fix a few ::DateMethods1 methods when using a bound date (vs a column)
+
+2.023005 2014-08-10 11:05:27-05:00 America/Chicago
+ - Fix ::Row::SelfResultSet to correctly include CSA (Thanks Steve Kleiman!)
+
+2.023004 2014-08-01 18:27:54-05:00 America/Chicago
+ - Fix implementation of ::Row::SelfResultSet (fixes GH#34, thanks ribasushi for
+ the heads up!)
+
+2.023003 2014-07-21 21:22:27-05:00 America/Chicago
+ - Fix ToJSON to use accessors if it needs to (Thanks Kevin Benson!)
+ - Fix silly typo in ::Explain (Good catch Jonathan W. Taylor!)
+
+2.023002 2014-06-28 15:04:15-05:00 America/Chicago
+ - Remove silly layer of subtesting (thanks to new features in Test::Roo)
+ - Remove silly sub wrapper in Explain internals (should moderately increase
+ performance)
+
+2.023001 2014-06-14 12:39:08-05:00 America/Chicago
+ - Add handy SYNOPSIS to ::DateMethods1 (thanks for asking rjbs!)
+
2.023000 2014-05-26 19:33:01-05:00 America/Chicago
- Add ::Shortcut::Explain RS helper
@@ -1,4 +1,4 @@
-# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.017.
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.020.
CONTRIBUTING
Changes
LICENSE
@@ -86,12 +86,14 @@ t/lib/TestSchema/Result/Foo.pm
t/lib/TestSchema/Result/Foo_Bar.pm
t/lib/TestSchema/Result/Gnarly.pm
t/lib/TestSchema/Result/Gnarly_Station.pm
+t/lib/TestSchema/Result/HasAccessor.pm
t/lib/TestSchema/Result/HasDateOps.pm
t/lib/TestSchema/Result/Station.pm
t/lib/TestSchema/ResultSet.pm
t/lib/TestSchema/ResultSet/Bloaty.pm
t/lib/TestSchema/ResultSet/Foo.pm
t/lib/TestSchema/ResultSet/Gnarly.pm
+t/lib/TestSchema/ResultSet/HasAccessor.pm
t/lib/TestSchema/ResultSet/HasDateOps.pm
t/lib/TestSchema/ResultSet/Station.pm
t/release-pod-syntax.t
@@ -4,7 +4,7 @@
"Arthur Axel \"fREW\" Schmidt <frioux+cpan@gmail.com>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 5.017, CPAN::Meta::Converter version 2.140640",
+ "generated_by" : "Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.142060",
"license" : [
"perl_5"
],
@@ -16,7 +16,7 @@
"prereqs" : {
"configure" : {
"requires" : {
- "ExtUtils::MakeMaker" : "6.30"
+ "ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
@@ -48,7 +48,7 @@
"Test::Deep" : "0",
"Test::Exception" : "0",
"Test::More" : "0.94",
- "Test::Roo" : "0"
+ "Test::Roo" : "1.003"
}
}
},
@@ -64,6 +64,6 @@
"web" : "https://github.com/frioux/DBIx-Class-Helpers"
}
},
- "version" : "2.023000"
+ "version" : "2.023007"
}
@@ -8,11 +8,11 @@ build_requires:
Test::Deep: '0'
Test::Exception: '0'
Test::More: '0.94'
- Test::Roo: '0'
+ Test::Roo: '1.003'
configure_requires:
- ExtUtils::MakeMaker: '6.30'
+ ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'Dist::Zilla version 5.017, CPAN::Meta::Converter version 2.140640'
+generated_by: 'Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.142060'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -36,4 +36,4 @@ resources:
bugtracker: https://github.com/frioux/DBIx-Class-Helpers/issues
homepage: https://github.com/frioux/DBIx-Class-Helpers
repository: https://github.com/frioux/DBIx-Class-Helpers.git
-version: '2.023000'
+version: '2.023007'
@@ -1,11 +1,11 @@
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.017.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.020.
use strict;
use warnings;
-use ExtUtils::MakeMaker 6.30;
+use ExtUtils::MakeMaker ;
@@ -13,7 +13,7 @@ my %WriteMakefileArgs = (
"ABSTRACT" => "Simplify the common case stuff for DBIx::Class.",
"AUTHOR" => "Arthur Axel \"fREW\" Schmidt <frioux+cpan\@gmail.com>",
"CONFIGURE_REQUIRES" => {
- "ExtUtils::MakeMaker" => "6.30"
+ "ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "DBIx-Class-Helpers",
"EXE_FILES" => [],
@@ -40,9 +40,9 @@ my %WriteMakefileArgs = (
"Test::Deep" => 0,
"Test::Exception" => 0,
"Test::More" => "0.94",
- "Test::Roo" => 0
+ "Test::Roo" => "1.003"
},
- "VERSION" => "2.023000",
+ "VERSION" => "2.023007",
"test" => {
"TESTS" => "t/*.t t/resultset/*.t t/resultset/date-methods-1/*.t t/resultset/shortcut/*.t t/row/*.t t/schema/*.t"
}
@@ -65,7 +65,7 @@ my %FallbackPrereqs = (
"Test::Deep" => 0,
"Test::Exception" => 0,
"Test::More" => "0.94",
- "Test::Roo" => 0,
+ "Test::Roo" => "1.003",
"Try::Tiny" => 0,
"namespace::clean" => "0.23",
"parent" => 0
@@ -15,7 +15,7 @@ requires 'Safe::Isa';
on test => sub {
requires 'Test::More' => 0.94;
requires 'Test::Deep' => 0;
- requires 'Test::Roo' => 0;
+ requires 'Test::Roo' => 1.003;
requires 'DBD::SQLite' => 0;
requires 'Test::Exception' => 0;
requires 'DateTime::Format::SQLite' => 0;
@@ -2,7 +2,9 @@ name = DBIx-Class-Helpers
author = Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
license = Perl_5
copyright_holder = Arthur Axel "fREW" Schmidt
-version = 2.023000
+version = 2.023007
+
+; authordep Pod::Weaver::Plugin::Exec
[NextRelease]
[@Git]
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::IgnoreWantarray;
-$DBIx::Class::Helper::IgnoreWantarray::VERSION = '2.023000';
+$DBIx::Class::Helper::IgnoreWantarray::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::ResultSet::IgnoreWantarray';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::JoinTable;
-$DBIx::Class::Helper::JoinTable::VERSION = '2.023000';
+$DBIx::Class::Helper::JoinTable::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::Row::JoinTable';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Random;
-$DBIx::Class::Helper::Random::VERSION = '2.023000';
+$DBIx::Class::Helper::Random::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::ResultSet::Random';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::AutoRemoveColumns;
-$DBIx::Class::Helper::ResultSet::AutoRemoveColumns::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::AutoRemoveColumns::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::CorrelateRelationship;
-$DBIx::Class::Helper::ResultSet::CorrelateRelationship::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::CorrelateRelationship::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,10 +1,11 @@
package DBIx::Class::Helper::ResultSet::DateMethods1;
-$DBIx::Class::Helper::ResultSet::DateMethods1::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::DateMethods1::VERSION = '2.023007';
# ABSTRACT: Work with dates in your RDBMS nicely
use strict;
use warnings;
+use DBI qw(:sql_types);
use DBIx::Introspector;
use Safe::Isa;
@@ -59,11 +60,11 @@ sub _introspector {
sub {
my ($date_sql, $part) = @_;
- my $sql = delete $date_sql->[0];
+ my ($sql, @args) = @$date_sql;
return [
"DATEPART($part_map{$part}, $sql)",
- @$date_sql
+ @args
]
}
});
@@ -110,11 +111,11 @@ sub _introspector {
sub {
my ($date_sql, $part) = @_;
- my $sql = delete $date_sql->[0];
+ my ($sql, @args) = @$date_sql;
return [
"STRFTIME('%$part_map{$part}', $sql)",
- @$date_sql
+ @args
]
}
});
@@ -182,11 +183,13 @@ sub _introspector {
sub {
my ($date_sql, $part) = @_;
- my $sql = delete $date_sql->[0];
+ my ($sql, @args) = @$date_sql;
+ @args = ([{ dbd_attrs => SQL_TIMESTAMP }, $args[0]])
+ if $sql eq '?' && @args == 1;
return [
"date_part(?, $sql)",
- $part_map{$part}, @$date_sql
+ $part_map{$part}, @args
]
}
});
@@ -198,6 +201,9 @@ sub _introspector {
my ($d_sql, @d_args) = @{$date_sql};
my ($a_sql, @a_args) = @{$amount_sql};
+ @d_args = ([{ dbd_attrs => SQL_TIMESTAMP }, $d_args[0]])
+ if $d_sql eq '?' && @d_args == 1;
+
die "unknown part $unit" unless $diff_part_map{$unit};
return [
@@ -244,10 +250,10 @@ sub _introspector {
sub {
my ($date_sql, $part) = @_;
- my $sql = delete $date_sql->[0];
+ my ($sql, @args) = @$date_sql;
return [
- "EXTRACT($part_map{$part} FROM $sql)", @$date_sql
+ "EXTRACT($part_map{$part} FROM $sql)", @args
]
}
});
@@ -283,12 +289,10 @@ sub _introspector {
sub {
my ($date_sql, $part) = @_;
- my $sql = delete $date_sql->[0];
+ my ($sql, @args) = @$date_sql;
- $sql = "TO_TIMESTAMP($sql)"
- if $part =~ /second|minute|hour/;
return [
- "EXTRACT($part_map{$part} FROM $sql)", @$date_sql
+ "EXTRACT($part_map{$part} FROM TO_TIMESTAMP($sql))", @args
]
}
});
@@ -306,7 +310,7 @@ sub _introspector {
die "unknown unit $unit" unless $diff_part_map{$unit};
return [
- "($d_sql + NUMTODSINTERVAL($a_sql, ?))",
+ "(TO_TIMESTAMP($d_sql) + NUMTODSINTERVAL($a_sql, ?))",
@d_args, @a_args, $diff_part_map{$unit}
];
}
@@ -429,6 +433,38 @@ __END__
DBIx::Class::Helper::ResultSet::DateMethods1 - Work with dates in your RDBMS nicely
+=head1 SYNOPSIS
+
+ package MySchema::ResultSet::Bar;
+
+ use strict;
+ use warnings;
+
+ use parent 'DBIx::Class::ResultSet';
+
+ __PACKAGE__->load_components('Helper::ResultSet::DateMethods1');
+
+ # in code using resultset
+
+ # get count per year/month
+ $rs->search(undef, {
+ columns => {
+ count => '*',
+ year => $rs->dt_SQL_pluck({ -ident => '.start' }, 'year'),
+ month => $rs->dt_SQL_pluck({ -ident => '.start' }, 'month'),
+ },
+ group_by => [
+ $rs->dt_SQL_pluck({ -ident => '.start' }, 'year'),
+ $rs->dt_SQL_pluck({ -ident => '.start' }, 'month'),
+ ],
+ });
+
+ # mysql
+ (SELECT `me`.*, EXTRACT(MONTH FROM `me`.`start`), EXTRACT(YEAR FROM `me`.`start`) FROM `HasDateOps` `me` GROUP BY EXTRACT(YEAR FROM `me`.`start`), EXTRACT(MONTH FROM `me`.`start`))
+
+ # SQLite
+ (SELECT "me".*, STRFTIME('%m', "me"."start"), STRFTIME('%Y', "me"."start") FROM "HasDateOps" "me" GROUP BY STRFTIME('%Y', "me"."start"), STRFTIME('%m', "me"."start"))
+
=head1 DESCRIPTION
See L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it
@@ -965,7 +1001,7 @@ for what units are accepted.
year => $rs->dt_SQL_pluck({ -ident => '.start' }, 'year'),
},
group_by => [$rs->dt_SQL_pluck({ -ident => '.start' }, 'year')],
- )->hri->all
+ })->hri->all
Takes two arguments: a date conforming to L</TYPES> and a unit. The idea
is to pluck a given unit from the datetime. See your L</IMPLEMENTATION>
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Explain;
-$DBIx::Class::Helper::ResultSet::Explain::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Explain::VERSION = '2.023007';
use strict;
use warnings;
@@ -76,7 +76,7 @@ DBIx::Class::Helper::ResultSet::Explain - Get query plan for a ResultSet
This module mostly makes sense to be used without setting as a component:
- ues Devel::Dwarn;
+ use Devel::Dwarn;
Dwarn DBIx::Class::ResultSet::Explain::explain($rs)
But as usual, if you prefer to use it as a component here's how:
@@ -223,7 +223,7 @@ to your entire schema.
"Transaction",
0,
0,
- 14,
+ 15,
0,
"01",
undef
@@ -254,10 +254,10 @@ to your entire schema.
[
[
- "Seq Scan on \"Gnarly\" me (cost=0.00..16.20 rows=620 width=100) (actual time=0.003..0.003 rows=0 loops=1)"
+ "Seq Scan on \"Gnarly\" me (cost=0.00..16.20 rows=620 width=100) (actual time=0.001..0.001 rows=0 loops=1)"
],
[
- "Total runtime: 0.056 ms"
+ "Total runtime: 0.020 ms"
]
]
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::IgnoreWantarray;
-$DBIx::Class::Helper::ResultSet::IgnoreWantarray::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::IgnoreWantarray::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Me;
-$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::NoColumns;
-$DBIx::Class::Helper::ResultSet::NoColumns::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::NoColumns::VERSION = '2.023007';
# ABSTRACT: Look ma, no columns!
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Random;
-$DBIx::Class::Helper::ResultSet::Random::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Random::VERSION = '2.023007';
use strict;
use warnings;
@@ -12,11 +12,11 @@ sub _introspector {
my $d = use_module('DBIx::Introspector')
->new(drivers => '2013-12.01');
- $d->decorate_driver_unconnected(ACCESS => rand_sql => sub { 'RND()' });
- $d->decorate_driver_unconnected(Oracle => rand_sql => sub { 'dbms_random.value' });
- $d->decorate_driver_unconnected(Pg => rand_sql => sub { 'RANDOM()' });
- $d->decorate_driver_unconnected(MSSQL => rand_sql => sub { 'NEWID()' });
- $d->decorate_driver_unconnected(SQLite => rand_sql => sub { 'RANDOM()' });
+ $d->decorate_driver_unconnected(ACCESS => rand_sql => 'RND()' );
+ $d->decorate_driver_unconnected(Oracle => rand_sql => 'dbms_random.value' );
+ $d->decorate_driver_unconnected(Pg => rand_sql => 'RANDOM()' );
+ $d->decorate_driver_unconnected(MSSQL => rand_sql => 'NEWID()' );
+ $d->decorate_driver_unconnected(SQLite => rand_sql => 'RANDOM()' );
$d
}
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::RemoveColumns;
-$DBIx::Class::Helper::ResultSet::RemoveColumns::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::RemoveColumns::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::ResultClassDWIM;
-$DBIx::Class::Helper::ResultSet::ResultClassDWIM::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::ResultClassDWIM::VERSION = '2.023007';
# ABSTRACT: result_class => '::HRI' == WIN
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::SearchOr;
-$DBIx::Class::Helper::ResultSet::SearchOr::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::SearchOr::VERSION = '2.023007';
# ABSTRACT: Combine ResultSet searches with OR's
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::SetOperations;
-$DBIx::Class::Helper::ResultSet::SetOperations::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::SetOperations::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::AddColumns;
-$DBIx::Class::Helper::ResultSet::Shortcut::AddColumns::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::AddColumns::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Columns;
-$DBIx::Class::Helper::ResultSet::Shortcut::Columns::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Columns::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Distinct;
-$DBIx::Class::Helper::ResultSet::Shortcut::Distinct::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Distinct::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::GroupBy;
-$DBIx::Class::Helper::ResultSet::Shortcut::GroupBy::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::GroupBy::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::HRI;
-$DBIx::Class::Helper::ResultSet::Shortcut::HRI::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::HRI::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::HasRows;
-$DBIx::Class::Helper::ResultSet::Shortcut::HasRows::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::HasRows::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Limit;
-$DBIx::Class::Helper::ResultSet::Shortcut::Limit::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Limit::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage;
-$DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::OrderBy;
-$DBIx::Class::Helper::ResultSet::Shortcut::OrderBy::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::OrderBy::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic;
-$DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Page;
-$DBIx::Class::Helper::ResultSet::Shortcut::Page::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Page::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Prefetch;
-$DBIx::Class::Helper::ResultSet::Shortcut::Prefetch::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Prefetch::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist;
-$DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Rows;
-$DBIx::Class::Helper::ResultSet::Shortcut::Rows::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::Rows::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut;
-$DBIx::Class::Helper::ResultSet::Shortcut::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Shortcut::VERSION = '2.023007';
# ABSTRACT: Shortcuts to common searches (->order_by, etc)
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Union;
-$DBIx::Class::Helper::ResultSet::Union::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::Union::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::ResultSet::SetOperations';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::VirtualView;
-$DBIx::Class::Helper::ResultSet::VirtualView::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::VirtualView::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet;
-$DBIx::Class::Helper::ResultSet::VERSION = '2.023000';
+$DBIx::Class::Helper::ResultSet::VERSION = '2.023007';
use parent qw{
DBIx::Class::Helper::ResultSet::AutoRemoveColumns
DBIx::Class::Helper::ResultSet::CorrelateRelationship
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::CleanResultSet;
-$DBIx::Class::Helper::Row::CleanResultSet::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::CleanResultSet::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::JoinTable;
-$DBIx::Class::Helper::Row::JoinTable::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::JoinTable::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::NumifyGet;
-$DBIx::Class::Helper::Row::NumifyGet::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::NumifyGet::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::OnColumnChange;
-$DBIx::Class::Helper::Row::OnColumnChange::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::OnColumnChange::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ProxyResultSetMethod;
-$DBIx::Class::Helper::Row::ProxyResultSetMethod::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::ProxyResultSetMethod::VERSION = '2.023007';
use strict;
use warnings;
@@ -40,7 +40,7 @@ sub proxy_resultset_method {
}
sub copy {
- delete local @{$_[0]->{_column_data}}{@{$_[0]->_proxy_slots}};
+ delete local @{$_[0]->{_column_data}}{@{$_[0]->_proxy_slots||[]}};
shift->next::method(@_);
}
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ProxyResultSetUpdate;
-$DBIx::Class::Helper::Row::ProxyResultSetUpdate::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::ProxyResultSetUpdate::VERSION = '2.023007';
# ABSTRACT: Efficiently reuse ResultSet updates from results
use base 'DBIx::Class::Helper::Row::SelfResultSet';
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::RelationshipDWIM;
-$DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::SelfResultSet;
-$DBIx::Class::Helper::Row::SelfResultSet::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::SelfResultSet::VERSION = '2.023007';
use strict;
use warnings;
@@ -8,13 +8,8 @@ use warnings;
sub self_rs {
my ($self) = @_;
- my $src = $self->result_source;
- my $rs = $src->resultset;
- my $me = $rs->current_source_alias;
- return $rs->search({
- # perl, sometimes I hate your guts
- map +( "$me.$_" => $self->get_column($_) ), $src->primary_columns
- })
+ my $rs = $self->result_source->resultset;
+ return $rs->search( $self->ident_condition( $rs->current_source_alias ) );
}
1;
@@ -44,6 +39,12 @@ row. A good reason to do that would be if you had a ResultSet method that adds
in some calculated data, like counts of a relationship. You could use this to
get at that counted data without duplicating the logic for the counting.
+Due to primitives provided by L<DBIx::Class::PK> this references the current
+values, or in C<DBIx::Class> terms, the dirty values. So if you modify the
+primary columns it will be temporarily incorrect. For what it's worth I'm not
+married to this behavior and I'd rather you get in touch with me before you
+depend on it.
+
=head1 METHODS
=head2 self_rs
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::StorageValues;
-$DBIx::Class::Helper::Row::StorageValues::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::StorageValues::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::SubClass;
-$DBIx::Class::Helper::Row::SubClass::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::SubClass::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ToJSON;
-$DBIx::Class::Helper::Row::ToJSON::VERSION = '2.023000';
+$DBIx::Class::Helper::Row::ToJSON::VERSION = '2.023007';
use strict;
use warnings;
@@ -47,9 +47,12 @@ sub serializable_columns {
sub TO_JSON {
my $self = shift;
+ my $columns_info = $self->columns_info($self->serializable_columns);
+
return {
map +($_ => $self->$_),
- @{$self->serializable_columns}
+ map +($columns_info->{$_}{accessor} || $_),
+ keys %$columns_info
};
}
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::DateTime;
-$DBIx::Class::Helper::Schema::DateTime::VERSION = '2.023000';
+$DBIx::Class::Helper::Schema::DateTime::VERSION = '2.023007';
# ABSTRACT: DateTime helper
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::GenerateSource;
-$DBIx::Class::Helper::Schema::GenerateSource::VERSION = '2.023000';
+$DBIx::Class::Helper::Schema::GenerateSource::VERSION = '2.023007';
# ABSTRACT: Generate sources directly from your Schema
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::LintContents;
-$DBIx::Class::Helper::Schema::LintContents::VERSION = '2.023000';
+$DBIx::Class::Helper::Schema::LintContents::VERSION = '2.023007';
# ABSTRACT: suite of methods to find violated "constraints"
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::QuoteNames;
-$DBIx::Class::Helper::Schema::QuoteNames::VERSION = '2.023000';
+$DBIx::Class::Helper::Schema::QuoteNames::VERSION = '2.023007';
# ABSTRACT: force C<quote_names> on
use strict;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::SubClass;
-$DBIx::Class::Helper::SubClass::VERSION = '2.023000';
+$DBIx::Class::Helper::SubClass::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::Row::SubClass';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::VirtualView;
-$DBIx::Class::Helper::VirtualView::VERSION = '2.023000';
+$DBIx::Class::Helper::VirtualView::VERSION = '2.023007';
use parent 'DBIx::Class::Helper::ResultSet::VirtualView';
use Carp::Clan;
@@ -1,5 +1,5 @@
package DBIx::Class::Helpers::Util;
-$DBIx::Class::Helpers::Util::VERSION = '2.023000';
+$DBIx::Class::Helpers::Util::VERSION = '2.023007';
use strict;
use warnings;
@@ -1,5 +1,5 @@
package DBIx::Class::Helpers;
-$DBIx::Class::Helpers::VERSION = '2.023000';
+$DBIx::Class::Helpers::VERSION = '2.023007';
use strict;
use warnings;
@@ -327,26 +327,51 @@ test add => sub {
$self->rs->delete;
$self->rs->create({ id => 1, a_date => $self->rs->utc($dt) });
- my $added = $self->rs->search(undef, {
- rows => 1,
- columns => { foo =>
- $self->rs->dt_SQL_add(
+ subtest column => sub {
+ my $added = $self->rs->search(undef, {
+ rows => 1,
+ columns => { foo =>
$self->rs->dt_SQL_add(
- $self->rs->dt_SQL_add({ -ident => '.a_date' }, 'minute', 2),
- second => 4,
- ), hour => 1,
- ),
- },
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
- })->first->{foo};
- $added = $self->parse_datetime($added);
-
- is($added->year => 2013, 'added year');
- is($added->month => 12, 'added month');
- is($added->day => 11, 'added day');
- is($added->hour => 11, 'added hour');
- is($added->minute => 11, 'added minute');
- is($added->second => 12, 'added second');
+ $self->rs->dt_SQL_add(
+ $self->rs->dt_SQL_add({ -ident => '.a_date' }, 'minute', 2),
+ second => 4,
+ ), hour => 1,
+ ),
+ },
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ })->first->{foo};
+ $added = $self->parse_datetime($added);
+
+ is($added->year => 2013, 'added year');
+ is($added->month => 12, 'added month');
+ is($added->day => 11, 'added day');
+ is($added->hour => 11, 'added hour');
+ is($added->minute => 11, 'added minute');
+ is($added->second => 12, 'added second');
+ };
+
+ subtest bindarg => sub {
+ my $added = $self->rs->search(undef, {
+ rows => 1,
+ columns => { foo =>
+ $self->rs->dt_SQL_add(
+ $self->rs->dt_SQL_add(
+ $self->rs->dt_SQL_add($dt, 'minute', 2),
+ second => 4,
+ ), hour => 1,
+ ),
+ },
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ })->first->{foo};
+ $added = $self->parse_datetime($added);
+
+ is($added->year => 2013, 'added year');
+ is($added->month => 12, 'added month');
+ is($added->day => 11, 'added day');
+ is($added->hour => 11, 'added hour');
+ is($added->minute => 11, 'added minute');
+ is($added->second => 12, 'added second');
+ };
}
};
@@ -428,21 +453,40 @@ test pluck => sub {
$self->rs->create({ id => 1, a_date => $self->rs->utc($dt) });
my @parts = qw(year month day_of_month hour minute second);
- my $plucked = $self->rs->search(undef, {
- rows => 1,
- select => [map $self->rs->dt_SQL_pluck({ -ident => '.a_date' }, $_), @parts],
- as => \@parts,
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
- })->first;
-
- cmp_deeply($plucked, {
- year => 2013,
- month => 12,
- day_of_month => 11,
- hour => 10,
- minute => $self->plucked_minute,
- second => $self->plucked_second,
- }, 'live pluck works');
+ {
+ my $plucked = $self->rs->search(undef, {
+ rows => 1,
+ select => [map $self->rs->dt_SQL_pluck({ -ident => '.a_date' }, $_), @parts],
+ as => \@parts,
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ })->first;
+
+ cmp_deeply($plucked, {
+ year => 2013,
+ month => 12,
+ day_of_month => 11,
+ hour => 10,
+ minute => $self->plucked_minute,
+ second => $self->plucked_second,
+ }, 'live pluck works from column');
+ }
+ {
+ my $plucked = $self->rs->search(undef, {
+ rows => 1,
+ select => [map $self->rs->dt_SQL_pluck($dt, $_), @parts],
+ as => \@parts,
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ })->first;
+
+ cmp_deeply($plucked, {
+ year => 2013,
+ month => 12,
+ day_of_month => 11,
+ hour => 10,
+ minute => $self->plucked_minute,
+ second => $self->plucked_second,
+ }, 'live pluck works from bindarg');
+ }
}
};
@@ -1,7 +1,8 @@
package TestSchema::Result::Bloaty;
use DBIx::Class::Candy -components => [
- 'Helper::Row::ProxyResultSetUpdate'
+ 'Helper::Row::ProxyResultSetUpdate',
+ 'Helper::Row::ProxyResultSetMethod',
];
table 'Bloaty';
@@ -0,0 +1,18 @@
+package TestSchema::Result::HasAccessor;
+
+use DBIx::Class::Candy
+ -components => [qw(
+ Helper::Row::ToJSON
+ )];
+
+
+table 'HasAccessor';
+
+primary_column id => { data_type => 'int' };;
+column usable_column => { data_type => 'varchar' };
+column unusable_column => {
+ data_type => 'varchar',
+ accessor => 'alternate_name',
+};
+
+1;
@@ -0,0 +1,9 @@
+package TestSchema::ResultSet::HasAccessor;
+use strict;
+use warnings;
+
+use parent 'TestSchema::ResultSet';
+
+__PACKAGE__->load_components();
+
+1;
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::MySQL
--- Created on Mon May 26 19:33:03 2014
+-- Created on Tue Sep 16 19:48:36 2014
--
SET foreign_key_checks=0;
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::Oracle
--- Created on Mon May 26 19:33:03 2014
+-- Created on Tue Sep 16 19:48:36 2014
--
--
-- Table: Gnarly
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
--- Created on Mon May 26 19:33:03 2014
+-- Created on Tue Sep 16 19:48:36 2014
--
--
-- Table: Gnarly.
@@ -1,9 +1,20 @@
--
-- Created by SQL::Translator::Generator::Role::DDL
--- Created on Mon May 26 19:33:03 2014
+-- Created on Tue Sep 16 19:48:36 2014
--
+--
+-- Turn off constraints
+--
+
+IF EXISTS (SELECT name FROM sysobjects WHERE name = 'HasDateOps' AND type = 'U') ALTER TABLE [HasDateOps] NOCHECK CONSTRAINT all;
+IF EXISTS (SELECT name FROM sysobjects WHERE name = 'Gnarly' AND type = 'U') ALTER TABLE [Gnarly] NOCHECK CONSTRAINT all;
+--
+-- Drop tables
+--
+IF EXISTS (SELECT name FROM sysobjects WHERE name = 'HasDateOps' AND type = 'U') DROP TABLE [HasDateOps];
+IF EXISTS (SELECT name FROM sysobjects WHERE name = 'Gnarly' AND type = 'U') DROP TABLE [Gnarly];
--
-- Table: [Gnarly]
--
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Mon May 26 19:33:03 2014
+-- Created on Tue Sep 16 19:48:36 2014
--
BEGIN TRANSACTION;
@@ -26,6 +26,15 @@ CREATE TABLE Gnarly (
);
--
+-- Table: HasAccessor
+--
+CREATE TABLE HasAccessor (
+ id INTEGER PRIMARY KEY NOT NULL,
+ usable_column varchar NOT NULL,
+ unusable_column varchar NOT NULL
+);
+
+--
-- Table: HasDateOps
--
CREATE TABLE HasDateOps (
@@ -65,7 +65,7 @@ sub generate_ddl {
sub prepopulate {
my $self = shift;
- $self->resultset($_)->delete for qw{Bar Foo Gnarly_Station Bloaty Gnarly Station};
+ $self->resultset($_)->delete for qw{Bar Foo Gnarly_Station Bloaty Gnarly Station HasAccessor};
$self->populate( Gnarly => [
[qw{id name}],
@@ -115,6 +115,13 @@ sub prepopulate {
[4,4],
[5,5],
]);
+
+ $self->populate( HasAccessor => [
+ [qw{id usable_column unusable_column}],
+ [1,'aa','bb'],
+ [2,'cc','dd'],
+ [3,'ee','ff'],
+ ]);
}
'kitten eater';
@@ -25,14 +25,26 @@ A::ResultSet::DateMethods1->run_tests(Oracle => {
storage_type => 'Oracle',
add_sql_prefix => \[
- '("me"."a_date" + NUMTODSINTERVAL(?, ?))', 1, 'SECOND',
+ '(TO_TIMESTAMP("me"."a_date") + NUMTODSINTERVAL(?, ?))', 1, 'SECOND',
],
add_sql_by_part => {
- day => \[ '("a_date" + NUMTODSINTERVAL(?, ?))', 1, 'DAY' ],
- hour => \[ '("a_date" + NUMTODSINTERVAL(?, ?))', 2, 'HOUR' ],
- minute => \[ '("a_date" + NUMTODSINTERVAL(?, ?))', 3, 'MINUTE' ],
- second => \[ '("a_date" + NUMTODSINTERVAL(?, ?))', 5, 'SECOND' ],
+ day => \[ '(TO_TIMESTAMP("a_date") + NUMTODSINTERVAL(?, ?))', 1, 'DAY' ],
+ hour => \[ '(TO_TIMESTAMP("a_date") + NUMTODSINTERVAL(?, ?))', 2, 'HOUR' ],
+ minute => \[ '(TO_TIMESTAMP("a_date") + NUMTODSINTERVAL(?, ?))', 3, 'MINUTE' ],
+ second => \[ '(TO_TIMESTAMP("a_date") + NUMTODSINTERVAL(?, ?))', 5, 'SECOND' ],
+ },
+
+ add_sql_by_part_result => {
+ day => '2012-12-13 00:00:00.000000000',
+ hour => '2012-12-12 02:00:00.000000000',
+ millisecond => '2012-12-12 00:00:00.007000000',
+ minute => '2012-12-12 00:03:00.000000000',
+ month => '2013-04-12 00:00:00.000000000',
+ quarter => '2015-03-12 00:00:00.000000000',
+ second => '2012-12-12 00:00:05.000000000',
+ week => '2013-02-20 00:00:00.000000000',
+ year => '2018-12-12 00:00:00.000000000',
},
pluck_sql_prefix => \[ 'EXTRACT(SECOND FROM TO_TIMESTAMP("me"."a_date"))' ],
@@ -41,9 +53,9 @@ A::ResultSet::DateMethods1->run_tests(Oracle => {
second => \[ 'EXTRACT(SECOND FROM TO_TIMESTAMP("a_date"))' ],
minute => \[ 'EXTRACT(MINUTE FROM TO_TIMESTAMP("a_date"))' ],
hour => \[ 'EXTRACT(HOUR FROM TO_TIMESTAMP("a_date"))' ],
- day_of_month => \[ 'EXTRACT(DAY FROM "a_date")' ],
- month => \[ 'EXTRACT(MONTH FROM "a_date")' ],
- year => \[ 'EXTRACT(YEAR FROM "a_date")' ],
+ day_of_month => \[ 'EXTRACT(DAY FROM TO_TIMESTAMP("a_date"))' ],
+ month => \[ 'EXTRACT(MONTH FROM TO_TIMESTAMP("a_date"))' ],
+ year => \[ 'EXTRACT(YEAR FROM TO_TIMESTAMP("a_date"))' ],
},
});
@@ -10,7 +10,7 @@ with 'A::Role::TestConnect';
sub rs { shift->schema->resultset('Gnarly') }
-test basic => sub {
+top_test basic => sub {
my $self = shift;
my $rs = $self->rs;
SKIP: {
@@ -38,5 +38,11 @@ subtest 'copy result' => sub {
is $g3->id, 100, 'id is correctly overridden';
};
+subtest 'copy result without any proxy defined' => sub {
+ my $bloaty = $schema->resultset('Bloaty')->first;
+ ok my $bcopy = $bloaty->copy({ id => 100, name => 'boo' }), 'Copied result';
+ is $bcopy->id, 100, 'id is correctly overridden';
+};
+
done_testing;
@@ -56,4 +56,25 @@ MORE_COMPLEX_JSON: {
}], 'complex TO_JSON works');
}
+ACCESSOR_CLASS: {
+ my $datas = [
+ map $_->TO_JSON,
+ $schema->resultset('HasAccessor')->search(undef, { order_by => 'id' })->all
+ ];
+
+ cmp_deeply($datas, [{
+ id => 1,
+ usable_column => 'aa',
+ alternate_name => 'bb',
+ },{
+ id => 2,
+ usable_column => 'cc',
+ alternate_name => 'dd',
+ },{
+ id => 3,
+ usable_column => 'ee',
+ alternate_name => 'ff',
+ }], 'accessor fields with TO_JSON works');
+}
+
done_testing;