@@ -1,5 +1,8 @@
Revision history for DBIx-Class-Helpers
+2.025000 2015-02-20 22:50:47-06:00 America/Chicago
+ - Add ::Helper::ResultSet::Errors to help when calling Result methods on an RS
+
2.024001 2014-11-25 19:16:41-06:00 America/Chicago
- Fix ::DidYouMean to override source instead of resultset (Thanks ribasushi
for the bug report!)
@@ -1,4 +1,4 @@
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@ b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
-This software is Copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is Copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software, licensed under:
@@ -272,7 +272,7 @@ That's all there is to it!
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is Copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software, licensed under:
@@ -1,4 +1,4 @@
-# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.020.
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.031.
CONTRIBUTING
Changes
LICENSE
@@ -18,6 +18,7 @@ lib/DBIx/Class/Helper/ResultSet/AutoRemoveColumns.pm
lib/DBIx/Class/Helper/ResultSet/CorrelateRelationship.pm
lib/DBIx/Class/Helper/ResultSet/DateMethods1.pm
lib/DBIx/Class/Helper/ResultSet/DateMethods1/Announcement.pod
+lib/DBIx/Class/Helper/ResultSet/Errors.pm
lib/DBIx/Class/Helper/ResultSet/Explain.pm
lib/DBIx/Class/Helper/ResultSet/IgnoreWantarray.pm
lib/DBIx/Class/Helper/ResultSet/Me.pm
@@ -64,6 +65,50 @@ lib/DBIx/Class/Helper/SubClass.pm
lib/DBIx/Class/Helper/VirtualView.pm
lib/DBIx/Class/Helpers.pm
lib/DBIx/Class/Helpers/Util.pm
+t/ResultSet/CorrelateRelationship.t
+t/ResultSet/DateMethods1/mssql.t
+t/ResultSet/DateMethods1/mysql.t
+t/ResultSet/DateMethods1/oracle.t
+t/ResultSet/DateMethods1/pg.t
+t/ResultSet/DateMethods1/sqlite.t
+t/ResultSet/Errors.t
+t/ResultSet/Explain.t
+t/ResultSet/IgnoreWantarray.t
+t/ResultSet/Me.t
+t/ResultSet/NoColumns.t
+t/ResultSet/Random.t
+t/ResultSet/RemoveColumns.t
+t/ResultSet/ResultClassDWIM.t
+t/ResultSet/SearchOr.t
+t/ResultSet/SetOperations.t
+t/ResultSet/Shortcut/AddColumns.t
+t/ResultSet/Shortcut/Columns.t
+t/ResultSet/Shortcut/Distinct.t
+t/ResultSet/Shortcut/GroupBy.t
+t/ResultSet/Shortcut/HRI.t
+t/ResultSet/Shortcut/HasRows.t
+t/ResultSet/Shortcut/Limit.t
+t/ResultSet/Shortcut/LimitedPage.t
+t/ResultSet/Shortcut/OrderBy.t
+t/ResultSet/Shortcut/OrderByMagic.t
+t/ResultSet/Shortcut/Prefetch.t
+t/ResultSet/Shortcut/ResultsExist.t
+t/ResultSet/Shortcut/Rows.t
+t/Row/CleanResultSet.t
+t/Row/JoinTable.t
+t/Row/NumifyGet.t
+t/Row/OnColumnChange.t
+t/Row/ProxyResultSetMethod.t
+t/Row/ProxyResultSetUpdate.t
+t/Row/RelationshipDWIM.t
+t/Row/SelfResultSet.t
+t/Row/StorageValues.t
+t/Row/SubClass.t
+t/Row/ToJSON.t
+t/Schema/DateTime.t
+t/Schema/DidYouMean.t
+t/Schema/GenerateSource.t
+t/Schema/LintContents.t
t/bug-1.t
t/lib/A/ResultSet/DateMethods1.pm
t/lib/A/Role/TestConnect.pm
@@ -98,48 +143,5 @@ t/lib/TestSchema/ResultSet/HasAccessor.pm
t/lib/TestSchema/ResultSet/HasDateOps.pm
t/lib/TestSchema/ResultSet/Station.pm
t/release-pod-syntax.t
-t/resultset/correlate-relationship.t
-t/resultset/date-methods-1/mssql.t
-t/resultset/date-methods-1/mysql.t
-t/resultset/date-methods-1/oracle.t
-t/resultset/date-methods-1/pg.t
-t/resultset/date-methods-1/sqlite.t
-t/resultset/explain.t
-t/resultset/ignore-wantarray.t
-t/resultset/me.t
-t/resultset/no-columns.t
-t/resultset/random.t
-t/resultset/remove-columns.t
-t/resultset/result-class-dwim.t
-t/resultset/search-or.t
-t/resultset/set-operations.t
-t/resultset/shortcut/add-columns.t
-t/resultset/shortcut/columns.t
-t/resultset/shortcut/distinct.t
-t/resultset/shortcut/group-by.t
-t/resultset/shortcut/has-rows.t
-t/resultset/shortcut/hri.t
-t/resultset/shortcut/limit.t
-t/resultset/shortcut/limited-page.t
-t/resultset/shortcut/order-by-magic.t
-t/resultset/shortcut/order-by.t
-t/resultset/shortcut/prefetch.t
-t/resultset/shortcut/results-exist.t
-t/resultset/shortcut/rows.t
-t/row/clean-resultset.t
-t/row/jointable.t
-t/row/numifyget.t
-t/row/on-column-change.t
-t/row/proxy-resultset-method.t
-t/row/proxy-resultset-update.t
-t/row/relationship-dwim.t
-t/row/self-resultset.t
-t/row/storage-values.t
-t/row/subclass.t
-t/row/to_json.t
-t/schema/datetime.t
-t/schema/did-you-mean.t
-t/schema/generate-source.t
-t/schema/lint-contents.t
t/utilities.t
weaver.ini
@@ -4,7 +4,7 @@
"Arthur Axel \"fREW\" Schmidt <frioux+cpan@gmail.com>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.142060",
+ "generated_by" : "Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.142060",
"license" : [
"perl_5"
],
@@ -65,6 +65,6 @@
"web" : "https://github.com/frioux/DBIx-Class-Helpers"
}
},
- "version" : "2.024001"
+ "version" : "2.025000"
}
@@ -12,7 +12,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.142060'
+generated_by: 'Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.142060'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -37,4 +37,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.024001'
+version: '2.025000'
@@ -1,11 +1,11 @@
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.020.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.031.
use strict;
use warnings;
-use ExtUtils::MakeMaker ;
+use ExtUtils::MakeMaker;
@@ -43,9 +43,9 @@ my %WriteMakefileArgs = (
"Test::More" => "0.94",
"Test::Roo" => "1.003"
},
- "VERSION" => "2.024001",
+ "VERSION" => "2.025000",
"test" => {
- "TESTS" => "t/*.t t/resultset/*.t t/resultset/date-methods-1/*.t t/resultset/shortcut/*.t t/row/*.t t/schema/*.t"
+ "TESTS" => "t/*.t t/ResultSet/*.t t/ResultSet/DateMethods1/*.t t/ResultSet/Shortcut/*.t t/Row/*.t t/Schema/*.t"
}
);
@@ -57,6 +57,7 @@ my %FallbackPrereqs = (
"DBIx::Class::Candy" => "0.001003",
"DBIx::Introspector" => "0.001002",
"DateTime::Format::SQLite" => 0,
+ "ExtUtils::MakeMaker" => 0,
"Lingua::EN::Inflect" => 0,
"List::Util" => 0,
"Module::Runtime" => 0,
@@ -1,58 +1,48 @@
-NAME
- DBIx::Class::Helpers - Simplify the common case stuff for DBIx::Class.
-
SYNOPSIS
- package MyApp::Schema::Result::Foo_Bar;
+ package MyApp::Schema::Result::Foo_Bar;
+
__PACKAGE__->load_components(qw{Helper::JoinTable Core});
-
+
__PACKAGE__->join_table({
left_class => 'Foo',
left_method => 'foo',
right_class => 'Bar',
right_method => 'bar',
});
-
+
# define parent class
package ParentSchema::Result::Bar;
-
+
use strict;
use warnings;
-
+
use parent 'DBIx::Class';
-
+
__PACKAGE__->load_components('Core');
-
+
__PACKAGE__->table('Bar');
-
+
__PACKAGE__->add_columns(qw/ id foo_id /);
-
+
__PACKAGE__->set_primary_key('id');
-
+
__PACKAGE__->belongs_to( foo => 'ParentSchema::Result::Foo', 'foo_id' );
-
+
# define subclass
package MySchema::Result::Bar;
-
+
use strict;
use warnings;
-
+
use parent 'ParentSchema::Result::Bar';
-
+
__PACKAGE__->load_components(qw{Helper::SubClass Core});
-
+
__PACKAGE__->subclass;
SEE ALSO
+
DBIx::Class::Helper::Row::JoinTable,
DBIx::Class::Helper::ResultSet::SubClass, DBIx::Class::Helpers::Util
-AUTHOR
- Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
-
-COPYRIGHT AND LICENSE
- This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
-
- This is free software; you can redistribute it and/or modify it under
- the same terms as the Perl 5 programming language system itself.
-
@@ -2,7 +2,7 @@ name = DBIx-Class-Helpers
author = Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
license = Perl_5
copyright_holder = Arthur Axel "fREW" Schmidt
-version = 2.024001
+version = 2.025000
; authordep Pod::Weaver::Plugin::Exec
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::IgnoreWantarray;
-$DBIx::Class::Helper::IgnoreWantarray::VERSION = '2.024001';
+$DBIx::Class::Helper::IgnoreWantarray::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::ResultSet::IgnoreWantarray';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::JoinTable;
-$DBIx::Class::Helper::JoinTable::VERSION = '2.024001';
+$DBIx::Class::Helper::JoinTable::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::Row::JoinTable';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Random;
-$DBIx::Class::Helper::Random::VERSION = '2.024001';
+$DBIx::Class::Helper::Random::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::ResultSet::Random';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::AutoRemoveColumns;
-$DBIx::Class::Helper::ResultSet::AutoRemoveColumns::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::AutoRemoveColumns::VERSION = '2.025000';
use strict;
use warnings;
@@ -141,7 +141,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::CorrelateRelationship;
-$DBIx::Class::Helper::ResultSet::CorrelateRelationship::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::CorrelateRelationship::VERSION = '2.025000';
use strict;
use warnings;
@@ -202,7 +202,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -142,7 +142,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::DateMethods1;
-$DBIx::Class::Helper::ResultSet::DateMethods1::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::DateMethods1::VERSION = '2.025000';
# ABSTRACT: Work with dates in your RDBMS nicely
use strict;
@@ -1013,7 +1013,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -0,0 +1,77 @@
+package DBIx::Class::Helper::ResultSet::Errors;
+$DBIx::Class::Helper::ResultSet::Errors::VERSION = '2.025000';
+# ABSTRACT: add exceptions to help when calling Result methods on an ResultSets
+
+use strict;
+use warnings;
+
+my $std_err = qq{Can't locate object method "%s" via package "%s" } .
+ qq{at %s line %d.\n};
+
+my $cust_err = qq{You're trying to call a Result ("%s") method ("%s") } .
+ qq{on a ResultSet ("%s") at %s line %d.\n};
+
+sub AUTOLOAD {
+ my $self = shift;
+
+ my($class) = ref $self || $self;
+
+ my($meth) = $DBIx::Class::Helper::ResultSet::Errors::AUTOLOAD
+ =~ m/::([^:]+)$/;
+
+ return if $meth eq 'DESTROY';
+
+ my($callpack, $callfile, $callline) = caller;
+
+ my $rclass = $self->result_source->result_class;
+
+ die sprintf $cust_err, $rclass, $meth, $class, $callfile, $callline
+ if $rclass->can($meth);
+
+ die sprintf $std_err, $meth, $class, $callfile, $callline;
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+DBIx::Class::Helper::ResultSet::Errors - add exceptions to help when calling Result methods on an ResultSets
+
+=head1 SYNOPSIS
+
+ package MyApp::Schema::ResultSet::Foo;
+
+ __PACKAGE__->load_components(qw{Helper::ResultSet::Errors});
+
+ ...
+
+ 1;
+
+And then in a script or something:
+
+ my $col = $rs->id
+
+ # dies with a helpful error!
+
+=head1 DESCRIPTION
+
+Users new to C<DBIx::Class> often make the mistake of treating ResultSets like
+Results. This helper ameliorates the situation by giving a helpful error when
+the user calls methods for the result on the ResultSet.
+
+=head1 AUTHOR
+
+Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Explain;
-$DBIx::Class::Helper::ResultSet::Explain::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Explain::VERSION = '2.025000';
use strict;
use warnings;
@@ -254,10 +254,13 @@ to your entire schema.
[
[
- "Seq Scan on \"Gnarly\" me (cost=0.00..16.20 rows=620 width=100) (actual time=0.000..0.000 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.013 ms"
+ "Planning time: 0.216 ms"
+ ],
+ [
+ "Execution time: 0.014 ms"
]
]
@@ -285,7 +288,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::IgnoreWantarray;
-$DBIx::Class::Helper::ResultSet::IgnoreWantarray::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::IgnoreWantarray::VERSION = '2.025000';
use strict;
use warnings;
@@ -59,7 +59,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Me;
-$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.025000';
use strict;
use warnings;
@@ -68,7 +68,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::NoColumns;
-$DBIx::Class::Helper::ResultSet::NoColumns::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::NoColumns::VERSION = '2.025000';
# ABSTRACT: Look ma, no columns!
use strict;
@@ -56,7 +56,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Random;
-$DBIx::Class::Helper::ResultSet::Random::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Random::VERSION = '2.025000';
use strict;
use warnings;
@@ -115,7 +115,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::RemoveColumns;
-$DBIx::Class::Helper::ResultSet::RemoveColumns::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::RemoveColumns::VERSION = '2.025000';
use strict;
use warnings;
@@ -80,7 +80,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::ResultClassDWIM;
-$DBIx::Class::Helper::ResultSet::ResultClassDWIM::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::ResultClassDWIM::VERSION = '2.025000';
# ABSTRACT: result_class => '::HRI' == WIN
use strict;
@@ -66,7 +66,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::SearchOr;
-$DBIx::Class::Helper::ResultSet::SearchOr::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::SearchOr::VERSION = '2.025000';
# ABSTRACT: Combine ResultSet searches with OR's
use strict;
@@ -132,7 +132,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::SetOperations;
-$DBIx::Class::Helper::ResultSet::SetOperations::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::SetOperations::VERSION = '2.025000';
use strict;
use warnings;
@@ -190,7 +190,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::AddColumns;
-$DBIx::Class::Helper::ResultSet::Shortcut::AddColumns::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::AddColumns::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Columns;
-$DBIx::Class::Helper::ResultSet::Shortcut::Columns::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Columns::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Distinct;
-$DBIx::Class::Helper::ResultSet::Shortcut::Distinct::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Distinct::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::GroupBy;
-$DBIx::Class::Helper::ResultSet::Shortcut::GroupBy::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::GroupBy::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::HRI;
-$DBIx::Class::Helper::ResultSet::Shortcut::HRI::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::HRI::VERSION = '2.025000';
use strict;
use warnings;
@@ -24,7 +24,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::HasRows;
-$DBIx::Class::Helper::ResultSet::Shortcut::HasRows::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::HasRows::VERSION = '2.025000';
use strict;
use warnings;
@@ -23,7 +23,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Limit;
-$DBIx::Class::Helper::ResultSet::Shortcut::Limit::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Limit::VERSION = '2.025000';
use strict;
use warnings;
@@ -23,7 +23,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage;
-$DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage::VERSION = '2.025000';
use strict;
use warnings;
@@ -42,7 +42,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::OrderBy;
-$DBIx::Class::Helper::ResultSet::Shortcut::OrderBy::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::OrderBy::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic;
-$DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic::VERSION = '2.025000';
use strict;
use warnings;
@@ -47,7 +47,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Page;
-$DBIx::Class::Helper::ResultSet::Shortcut::Page::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Page::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Prefetch;
-$DBIx::Class::Helper::ResultSet::Shortcut::Prefetch::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Prefetch::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist;
-$DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist::VERSION = '2.025000';
use strict;
use warnings;
@@ -29,7 +29,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut::Rows;
-$DBIx::Class::Helper::ResultSet::Shortcut::Rows::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::Rows::VERSION = '2.025000';
use strict;
use warnings;
@@ -21,7 +21,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Shortcut;
-$DBIx::Class::Helper::ResultSet::Shortcut::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Shortcut::VERSION = '2.025000';
# ABSTRACT: Shortcuts to common searches (->order_by, etc)
use strict;
@@ -224,7 +224,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::Union;
-$DBIx::Class::Helper::ResultSet::Union::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::Union::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::ResultSet::SetOperations';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet::VirtualView;
-$DBIx::Class::Helper::ResultSet::VirtualView::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::VirtualView::VERSION = '2.025000';
use strict;
use warnings;
@@ -101,7 +101,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::ResultSet;
-$DBIx::Class::Helper::ResultSet::VERSION = '2.024001';
+$DBIx::Class::Helper::ResultSet::VERSION = '2.025000';
use parent qw{
DBIx::Class::Helper::ResultSet::AutoRemoveColumns
DBIx::Class::Helper::ResultSet::CorrelateRelationship
@@ -65,7 +65,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::CleanResultSet;
-$DBIx::Class::Helper::Row::CleanResultSet::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::CleanResultSet::VERSION = '2.025000';
use strict;
use warnings;
@@ -47,7 +47,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::JoinTable;
-$DBIx::Class::Helper::Row::JoinTable::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::JoinTable::VERSION = '2.025000';
use strict;
use warnings;
@@ -338,7 +338,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::NumifyGet;
-$DBIx::Class::Helper::Row::NumifyGet::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::NumifyGet::VERSION = '2.025000';
use strict;
use warnings;
@@ -82,7 +82,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::OnColumnChange;
-$DBIx::Class::Helper::Row::OnColumnChange::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::OnColumnChange::VERSION = '2.025000';
use strict;
use warnings;
@@ -310,7 +310,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ProxyResultSetMethod;
-$DBIx::Class::Helper::Row::ProxyResultSetMethod::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::ProxyResultSetMethod::VERSION = '2.025000';
use strict;
use warnings;
@@ -151,7 +151,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ProxyResultSetUpdate;
-$DBIx::Class::Helper::Row::ProxyResultSetUpdate::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::ProxyResultSetUpdate::VERSION = '2.025000';
# ABSTRACT: Efficiently reuse ResultSet updates from results
use base 'DBIx::Class::Helper::Row::SelfResultSet';
@@ -86,7 +86,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::RelationshipDWIM;
-$DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.025000';
use strict;
use warnings;
@@ -93,7 +93,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::SelfResultSet;
-$DBIx::Class::Helper::Row::SelfResultSet::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::SelfResultSet::VERSION = '2.025000';
use strict;
use warnings;
@@ -59,7 +59,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::StorageValues;
-$DBIx::Class::Helper::Row::StorageValues::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::StorageValues::VERSION = '2.025000';
use strict;
use warnings;
@@ -159,7 +159,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::SubClass;
-$DBIx::Class::Helper::Row::SubClass::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::SubClass::VERSION = '2.025000';
use strict;
use warnings;
@@ -149,7 +149,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Row::ToJSON;
-$DBIx::Class::Helper::Row::ToJSON::VERSION = '2.024001';
+$DBIx::Class::Helper::Row::ToJSON::VERSION = '2.025000';
use strict;
use warnings;
@@ -155,7 +155,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::DateTime;
-$DBIx::Class::Helper::Schema::DateTime::VERSION = '2.024001';
+$DBIx::Class::Helper::Schema::DateTime::VERSION = '2.025000';
# ABSTRACT: DateTime helper
use strict;
@@ -39,7 +39,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::DidYouMean;
-$DBIx::Class::Helper::Schema::DidYouMean::VERSION = '2.024001';
+$DBIx::Class::Helper::Schema::DidYouMean::VERSION = '2.025000';
# ABSTRACT: Nice error messages when you misspell the name of a ResultSet
use strict;
@@ -80,7 +80,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::GenerateSource;
-$DBIx::Class::Helper::Schema::GenerateSource::VERSION = '2.024001';
+$DBIx::Class::Helper::Schema::GenerateSource::VERSION = '2.025000';
# ABSTRACT: Generate sources directly from your Schema
use strict;
@@ -82,7 +82,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::LintContents;
-$DBIx::Class::Helper::Schema::LintContents::VERSION = '2.024001';
+$DBIx::Class::Helper::Schema::LintContents::VERSION = '2.025000';
# ABSTRACT: suite of methods to find violated "constraints"
use strict;
@@ -228,7 +228,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::Schema::QuoteNames;
-$DBIx::Class::Helper::Schema::QuoteNames::VERSION = '2.024001';
+$DBIx::Class::Helper::Schema::QuoteNames::VERSION = '2.025000';
# ABSTRACT: force C<quote_names> on
use strict;
@@ -43,7 +43,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::SubClass;
-$DBIx::Class::Helper::SubClass::VERSION = '2.024001';
+$DBIx::Class::Helper::SubClass::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::Row::SubClass';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helper::VirtualView;
-$DBIx::Class::Helper::VirtualView::VERSION = '2.024001';
+$DBIx::Class::Helper::VirtualView::VERSION = '2.025000';
use parent 'DBIx::Class::Helper::ResultSet::VirtualView';
use Carp::Clan;
@@ -31,7 +31,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helpers::Util;
-$DBIx::Class::Helpers::Util::VERSION = '2.024001';
+$DBIx::Class::Helpers::Util::VERSION = '2.025000';
use strict;
use warnings;
@@ -242,7 +242,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -1,5 +1,5 @@
package DBIx::Class::Helpers;
-$DBIx::Class::Helpers::VERSION = '2.024001';
+$DBIx::Class::Helpers::VERSION = '2.025000';
use strict;
use warnings;
@@ -68,7 +68,7 @@ Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
+This software is copyright (c) 2015 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -0,0 +1,56 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Gnarly')->search(undef, {
+ '+columns' => {
+ old_gnarlies => $schema->resultset('Gnarly')
+ ->correlate('gnarly_stations')
+ ->search({ station_id => { '>' => 2 }})
+ ->count_rs->as_query,
+ new_gnarlies => $schema->resultset('Gnarly')
+ ->correlate('gnarly_stations')
+ ->search({ station_id => { '<=' => 2 }})
+ ->count_rs->as_query,
+ },
+ result_class => '::HRI',
+});
+
+cmp_deeply([$rs->all], [
+ {
+ id => 1,
+ literature => undef,
+ name => "frew",
+ new_gnarlies => 1,
+ old_gnarlies => 1,
+ your_mom => undef
+ },
+ {
+ id => 2,
+ literature => undef,
+ name => "frioux",
+ new_gnarlies => 1,
+ old_gnarlies => 0,
+ your_mom => undef
+ },
+ {
+ id => 3,
+ literature => undef,
+ name => "frooh",
+ new_gnarlies => 1,
+ old_gnarlies => 0,
+ your_mom => undef
+ }
+
+], 'relationship correlated correctly');
+
+done_testing;
@@ -0,0 +1,78 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib 't/lib';
+use A::ResultSet::DateMethods1;
+
+A::ResultSet::DateMethods1->run_tests(MSSQL => {
+ engine => 'MSSQL',
+ utc_now => 'GETUTCDATE()',
+ stringified_date => '2014-02-08 04:43:00.000',
+
+
+ storage_type => 'MSSQL',
+
+ add_sql_prefix => \[ 'DATEADD(second, CAST(? AS int), [me].[a_date])', 1 ],
+
+ add_sql_by_part_skip => {
+ nanosecond => "doesn't work with DATETIME data type",
+ },
+
+ add_sql_by_part => {
+ day => \[ 'DATEADD(dayofyear, CAST(? AS int), [a_date])', 1 ],
+ hour => \[ 'DATEADD(hour, CAST(? AS int), [a_date])', 2 ],
+ millisecond => \[ 'DATEADD(millisecond, CAST(? AS int), [a_date])', 7 ],
+ minute => \[ 'DATEADD(minute, CAST(? AS int), [a_date])', 3 ],
+ month => \[ 'DATEADD(month, CAST(? AS int), [a_date])', 4 ],
+ nanosecond => \[ 'DATEADD(nanosecond, CAST(? AS int), [a_date])', 8 ],
+ quarter => \[ 'DATEADD(quarter, CAST(? AS int), [a_date])', 9 ],
+ second => \[ 'DATEADD(second, CAST(? AS int), [a_date])', 5 ],
+ week => \[ 'DATEADD(week, CAST(? AS int), [a_date])', 10 ],
+ year => \[ 'DATEADD(year, CAST(? AS int), [a_date])', 6 ],
+ },
+
+ add_sql_by_part_result => {
+ day => '2012-12-13 00:00:00.000',
+ hour => '2012-12-12 02:00:00.000',
+ millisecond => '2012-12-12 00:00:00.007',
+ minute => '2012-12-12 00:03:00.000',
+ month => '2013-04-12 00:00:00.000',
+ quarter => '2015-03-12 00:00:00.000',
+ second => '2012-12-12 00:00:05.000',
+ week => '2013-02-20 00:00:00.000',
+ year => '2018-12-12 00:00:00.000',
+ },
+
+ pluck_sql_prefix => \[ q<DATEPART(second, [me].[a_date])> ],
+
+ pluck_sql_by_part => {
+ year => \[ 'DATEPART(year, [a_date])' ],
+ quarter => \[ 'DATEPART(quarter, [a_date])' ],
+ month => \[ 'DATEPART(month, [a_date])' ],
+ day_of_year => \[ 'DATEPART(dayofyear, [a_date])' ],
+ day_of_month => \[ 'DATEPART(day, [a_date])' ],
+ week => \[ 'DATEPART(week, [a_date])' ],
+ day_of_week => \[ 'DATEPART(ISO_WEEK, [a_date])' ],
+ hour => \[ 'DATEPART(hour, [a_date])' ],
+ minute => \[ 'DATEPART(minute, [a_date])' ],
+ second => \[ 'DATEPART(second, [a_date])' ],
+ millisecond => \[ 'DATEPART(millisecond, [a_date])' ],
+ nanosecond => \[ 'DATEPART(nanosecond, [a_date])' ],
+ non_iso_day_of_week => \[ 'DATEPART(weekday, [a_date])' ],
+ timezone_as_minutes => \[ 'DATEPART(TZoffset, [a_date])' ],
+ },
+
+ pluck_sql_by_part_skip => {
+ timezone_as_minutes => 'not supported by DateTime data type',
+ },
+
+ pluck_sql_by_part_result => {
+ millisecond => 0,
+ nanosecond => 0,
+ non_iso_day_of_week => 2,
+ },
+});
+
+done_testing;
@@ -0,0 +1,77 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib 't/lib';
+use A::ResultSet::DateMethods1;
+
+A::ResultSet::DateMethods1->run_tests(mysql => {
+ engine => 'mysql',
+ utc_now => 'UTC_TIMESTAMP()',
+ stringified_date => '2014-02-08 04:43:00',
+
+ storage_type => 'mysql',
+
+ pluck_sql_prefix => \[ 'EXTRACT(SECOND FROM `me`.`a_date`)' ],
+
+ pluck_sql_by_part => {
+ microsecond => \[ 'EXTRACT(MICROSECOND FROM `a_date`)' ],
+ second => \[ 'EXTRACT(SECOND FROM `a_date`)' ],
+ minute => \[ 'EXTRACT(MINUTE FROM `a_date`)' ],
+ hour => \[ 'EXTRACT(HOUR FROM `a_date`)' ],
+ day_of_month => \[ 'EXTRACT(DAY FROM `a_date`)' ],
+ week => \[ 'EXTRACT(WEEK FROM `a_date`)' ],
+ month => \[ 'EXTRACT(MONTH FROM `a_date`)' ],
+ quarter => \[ 'EXTRACT(QUARTER FROM `a_date`)' ],
+ year => \[ 'EXTRACT(YEAR FROM `a_date`)' ],
+ second_microsecond => \[ 'EXTRACT(SECOND_MICROSECOND FROM `a_date`)' ],
+ minute_microsecond => \[ 'EXTRACT(MINUTE_MICROSECOND FROM `a_date`)' ],
+ minute_second => \[ 'EXTRACT(MINUTE_SECOND FROM `a_date`)' ],
+ hour_microsecond => \[ 'EXTRACT(HOUR_MICROSECOND FROM `a_date`)' ],
+ hour_second => \[ 'EXTRACT(HOUR_SECOND FROM `a_date`)' ],
+ hour_minute => \[ 'EXTRACT(HOUR_MINUTE FROM `a_date`)' ],
+ day_microsecond => \[ 'EXTRACT(DAY_MICROSECOND FROM `a_date`)' ],
+ day_second => \[ 'EXTRACT(DAY_SECOND FROM `a_date`)' ],
+ day_minute => \[ 'EXTRACT(DAY_MINUTE FROM `a_date`)' ],
+ day_hour => \[ 'EXTRACT(DAY_HOUR FROM `a_date`)' ],
+ year_month => \[ 'EXTRACT(YEAR_MONTH FROM `a_date`)' ],
+ },
+
+ pluck_sql_by_part_result => {
+ microsecond => 0,
+ second_microsecond => '5000000',
+ minute_microsecond => '405000000',
+ minute_second => 405,
+ hour_microsecond => '30405000000',
+ hour_second => 30405,
+ hour_minute => 304,
+ day_microsecond => '2030405000000',
+ day_second => '2030405',
+ day_minute => 20304,
+ day_hour => 203,
+ year_month => '201201',
+ },
+
+ add_sql_prefix => \[ 'DATE_ADD(`me`.`a_date`, INTERVAL ? SECOND)', 1 ],
+
+ add_sql_by_part => {
+ day => \[ 'DATE_ADD(`a_date`, INTERVAL ? DAY)', 1 ],
+ hour => \[ 'DATE_ADD(`a_date`, INTERVAL ? HOUR)', 2 ],
+ microsecond => \[ 'DATE_ADD(`a_date`, INTERVAL ? MICROSECOND)', 7 ],
+ minute => \[ 'DATE_ADD(`a_date`, INTERVAL ? MINUTE)', 3 ],
+ month => \[ 'DATE_ADD(`a_date`, INTERVAL ? MONTH)', 4 ],
+ quarter => \[ 'DATE_ADD(`a_date`, INTERVAL ? QUARTER)', 8 ],
+ second => \[ 'DATE_ADD(`a_date`, INTERVAL ? SECOND)', 5 ],
+ week => \[ 'DATE_ADD(`a_date`, INTERVAL ? WEEK)', 9 ],
+ year => \[ 'DATE_ADD(`a_date`, INTERVAL ? YEAR)', 6 ],
+ },
+
+ add_sql_by_part_result => {
+ microsecond => '2012-12-12 00:00:00.000007',
+ quarter => '2014-12-12 00:00:00',
+ week => '2013-02-13 00:00:00',
+ },
+});
+
+done_testing;
@@ -0,0 +1,62 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib 't/lib';
+use A::ResultSet::DateMethods1;
+
+local $SIG{__WARN__} = sub {
+ my $warning = shift;
+
+ return if $warning =~
+ m/DBIx::Class::Storage::DBI::Oracle.*sql_(?:limit_dialect|quote_char)/;
+
+ print STDERR $warning;
+};
+
+A::ResultSet::DateMethods1->run_tests(Oracle => {
+ on_connect_call => 'datetime_setup',
+
+ engine => 'Oracle',
+ utc_now => 'sys_extract_utc(SYSTIMESTAMP)',
+ stringified_date => '2014-02-08 04:43:00',
+
+ storage_type => 'Oracle',
+
+ add_sql_prefix => \[
+ '(TO_TIMESTAMP("me"."a_date") + NUMTODSINTERVAL(?, ?))', 1, 'SECOND',
+ ],
+
+ add_sql_by_part => {
+ 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"))' ],
+
+ pluck_sql_by_part => {
+ 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 TO_TIMESTAMP("a_date"))' ],
+ month => \[ 'EXTRACT(MONTH FROM TO_TIMESTAMP("a_date"))' ],
+ year => \[ 'EXTRACT(YEAR FROM TO_TIMESTAMP("a_date"))' ],
+ },
+});
+
+done_testing;
@@ -0,0 +1,84 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib 't/lib';
+use A::ResultSet::DateMethods1;
+
+A::ResultSet::DateMethods1->run_tests(Pg => {
+ engine => 'Pg',
+ utc_now => 'CURRENT_TIMESTAMP',
+ stringified_date => '2014-02-08 04:43:00+0000',
+
+ storage_type => 'Pg',
+
+ add_sql_prefix => \[ q<("me"."a_date" + ? * interval '1 second')>, 1],
+
+ add_sql_by_part => {
+ century => \[ q<("a_date" + ? * interval '1 century')>, 7 ],
+ day => \[ q<("a_date" + ? * interval '1 day')>, 1 ],
+ decade => \[ q<("a_date" + ? * interval '1 decade')>, 8 ],
+ hour => \[ q<("a_date" + ? * interval '1 hour')>, 2 ],
+ microsecond => \[ q<("a_date" + ? * interval '1 microseconds')>, 9 ],
+ millisecond => \[ q<("a_date" + ? * interval '1 milliseconds')>, 10 ],
+ minute => \[ q<("a_date" + ? * interval '1 minute')>, 3 ],
+ month => \[ q<("a_date" + ? * interval '1 month')>, 4 ],
+ second => \[ q<("a_date" + ? * interval '1 second')>, 5 ],
+ week => \[ q<("a_date" + ? * interval '1 week')>, 11 ],
+ year => \[ q<("a_date" + ? * interval '1 year')>, 6 ],
+ },
+
+ add_sql_by_part_result => {
+ century => '2712-12-12 00:00:00',
+ decade => '2092-12-12 00:00:00',
+ microsecond => '2012-12-12 00:00:00.000009',
+ millisecond => '2012-12-12 00:00:00.01',
+ week => '2013-02-27 00:00:00',
+ },
+
+ pluck_sql_prefix => \[ 'date_part(?, "me"."a_date")', 'second' ],
+
+ pluck_sql_by_part => {
+ century => \[ 'date_part(?, "a_date")', 'century' ],
+ decade => \[ 'date_part(?, "a_date")', 'decade' ],
+ day_of_month => \[ 'date_part(?, "a_date")', 'day' ],
+ day_of_week => \[ 'date_part(?, "a_date")', 'dow' ],
+ day_of_year => \[ 'date_part(?, "a_date")', 'doy' ],
+ seconds_since_epoch => \[ 'date_part(?, "a_date")', 'epoch' ],
+ hour => \[ 'date_part(?, "a_date")', 'hour' ],
+ iso_day_of_week => \[ 'date_part(?, "a_date")', 'isodow' ],
+ iso_year => \[ 'date_part(?, "a_date")', 'isoyear' ],
+ microsecond => \[ 'date_part(?, "a_date")', 'microseconds' ],
+ millenium => \[ 'date_part(?, "a_date")', 'millenium' ],
+ millisecond => \[ 'date_part(?, "a_date")', 'milliseconds' ],
+ minute => \[ 'date_part(?, "a_date")', 'minute' ],
+ month => \[ 'date_part(?, "a_date")', 'month' ],
+ quarter => \[ 'date_part(?, "a_date")', 'quarter' ],
+ second => \[ 'date_part(?, "a_date")', 'second' ],
+ timezone => \[ 'date_part(?, "a_date")', 'timezone' ],
+ timezone_hour => \[ 'date_part(?, "a_date")', 'timezone_hour' ],
+ timezone_minute => \[ 'date_part(?, "a_date")', 'timezone_minute' ],
+ week => \[ 'date_part(?, "a_date")', 'week' ],
+ year => \[ 'date_part(?, "a_date")', 'year' ],
+ },
+
+ pluck_sql_by_part_skip => {
+ millenium => 'not supported by DateTime data type',
+ timezone => 'not supported by DateTime data type',
+ timezone_hour => 'not supported by DateTime data type',
+ timezone_minute => 'not supported by DateTime data type',
+ },
+
+ pluck_sql_by_part_result => {
+ century => 21,
+ decade => 201,
+ seconds_since_epoch => '1325473445',
+ iso_day_of_week => 1,
+ iso_year => 2012,
+ microsecond => '5000000',
+ millisecond => 5000,
+ },
+});
+
+done_testing;
@@ -0,0 +1,62 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib 't/lib';
+use A::ResultSet::DateMethods1;
+
+A::ResultSet::DateMethods1->run_tests(SQLite => {
+ engine => 'SQLite',
+ utc_now => q<DATETIME('now')>,
+ stringified_date => '2014-02-08 04:43:00',
+
+ plucked_minute => '09',
+ plucked_second => '08',
+
+ connect_info => [ 'dbi:SQLite::memory:' ],
+
+
+ add_sql_prefix => \[ 'DATETIME("me"."a_date", ? || ?)', 1, ' seconds' ],
+
+ add_sql_by_part => {
+ day => \[ 'DATETIME("a_date", ? || ?)', 1, ' days' ],
+ hour => \[ 'DATETIME("a_date", ? || ?)', 2, ' hours' ],
+ minute => \[ 'DATETIME("a_date", ? || ?)', 3, ' minutes' ],
+ month => \[ 'DATETIME("a_date", ? || ?)', 4, ' months' ],
+ second => \[ 'DATETIME("a_date", ? || ?)', 5, ' seconds' ],
+ year => \[ 'DATETIME("a_date", ? || ?)', 6, ' years' ],
+ },
+
+ pluck_sql_prefix => \[ q<STRFTIME('%S', "me"."a_date")> ],
+
+ pluck_sql_by_part => {
+ year => \[ q<STRFTIME('%Y', "a_date")> ],
+ month => \[ q<STRFTIME('%m', "a_date")> ],
+ day_of_month => \[ q<STRFTIME('%d', "a_date")> ],
+ hour => \[ q<STRFTIME('%H', "a_date")> ],
+ day_of_year => \[ q<STRFTIME('%j', "a_date")> ],
+ minute => \[ q<STRFTIME('%M', "a_date")> ],
+ second => \[ q<STRFTIME('%S', "a_date")> ],
+ day_of_week => \[ q<STRFTIME('%w', "a_date")> ],
+ week => \[ q<STRFTIME('%W', "a_date")> ],
+ julian_day => \[ q<STRFTIME('%J', "a_date")> ],
+ seconds_since_epoch => \[ q<STRFTIME('%s', "a_date")> ],
+ fractional_seconds => \[ q<STRFTIME('%f', "a_date")> ],
+ },
+
+ pluck_sql_by_part_result => {
+ month => '01',
+ day_of_month => '02',
+ hour => '03',
+ day_of_year => '002',
+ minute => '04',
+ second => '05',
+ week => '01',
+ julian_day => '2455928.627835648',
+ seconds_since_epoch => '1325473445',
+ fractional_seconds => '05.000',
+ },
+});
+
+done_testing;
@@ -0,0 +1,18 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Fatal;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+
+like exception {
+ $schema->resultset('Gnarly')->literature
+}, qr{^\QYou're trying to call a Result ("TestSchema::Result::Gnarly") method ("literature") on a ResultSet ("TestSchema::ResultSet::Gnarly") at t/ResultSet/Errors.t line 14.\E}, 'exceptional';
+
+done_testing;
+
@@ -0,0 +1,33 @@
+#!perl
+
+use Test::Roo;
+use Test::Fatal;
+use Data::Dumper::Concise;
+
+use lib 't/lib';
+
+with 'A::Role::TestConnect';
+
+sub rs { shift->schema->resultset('Gnarly') }
+
+top_test basic => sub {
+ my $self = shift;
+ my $rs = $self->rs;
+ SKIP: {
+ skip 'cannot test without a connection', 1 unless $self->connected;
+
+ my $s;
+ my $e = exception { $s = $rs->explain };
+ ok(!$e, 'valid SQL') or diag $e;
+ note(Dumper($s)) if $s;
+ }
+};
+
+run_me(SQLite => {
+ engine => 'SQLite',
+ connect_info => [ 'dbi:SQLite::memory:'],
+});
+run_me(Pg => { engine => 'Pg' });
+run_me(mysql => { engine => 'mysql' });
+
+done_testing;
@@ -0,0 +1,28 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Fatal;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my ($rs) = $schema->resultset('Foo')->search;
+my ($rs2) = $schema->resultset('Bar')->search;
+my ($rs3) = $schema->resultset('Foo')->first->bars;
+my ($rs4) = $schema->resultset('Bar')->first->foos;
+
+isa_ok $rs, 'DBIx::Class::ResultSet';
+isa_ok $rs2, 'DBIx::Class::ResultSet';
+isa_ok $rs3, 'DBIx::Class::ResultSet';
+isa_ok $rs4, 'DBIx::Class::ResultSet';
+
+like(exception {
+ $schema->resultset('Bar')->search
+}, qr/search is \*not\* a mutator/, 'correctly die in void ctx');
+
+done_testing;
@@ -0,0 +1,18 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+
+my $rs = $schema->resultset('Gnarly');
+my $alias = $rs->current_source_alias;
+
+is $rs->me, "$alias.", 'me without args';
+is $rs->me('col'), "$alias.col", 'me with args';
+
+done_testing;
@@ -0,0 +1,20 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Gnarly')->no_columns->search(undef, {
+ result_class => '::HRI',
+});
+
+cmp_deeply([$rs->all], [ { }, { }, { } ], 'no columns selected');
+
+done_testing;
@@ -0,0 +1,26 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Exception;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $row = $schema->resultset('Foo')->rand->single;
+# testing actual randomness is hard, and it's not actually random anyway,
+# so suck it.
+ok $row->id >= 1 && $row->id <= 5, 'row is one of the rows from the database';
+
+my @rows = map $_->id, $schema->resultset('Foo')->rand(4)->all;
+ok @rows == 4, 'correct amount of rows selected';
+for (@rows) {
+ ok $_ >= 1 && $_ <= 5, 'row is one of the rows from the database';
+}
+
+
+done_testing;
@@ -0,0 +1,68 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+use Test::Exception;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+RemoveColumns: {
+ my $rs = $schema->resultset('Foo')->search({
+ id => 1
+ }, {
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ 'remove_columns' => ['bar_id'],
+ });
+
+ cmp_deeply [$rs->all], [{ id => 1 }], 'remove_columns works';
+
+ cmp_deeply
+ [$rs->search({ id => { '!=' => 4 } })->all],
+ [{ id => 1 }],
+ 'chaining remove_columns works';;
+
+ cmp_deeply
+ [
+ $rs->search({
+ id => { '!=' => 4 }
+ }, {
+ '+columns' => 'bar_id'
+ })->all
+ ],
+ [{ bar_id => 1, id => 1 }],
+ 'chaining and +columns works with remove_columns';
+}
+
+AutoRemoveColumns: {
+ my $rs = $schema->resultset('Bloaty')->search({
+ id => 1
+ }, {
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ });
+
+ cmp_deeply [$rs->all], [{ id => 1 }], 'remove_columns works';
+
+ cmp_deeply
+ [$rs->search({ id => { '!=' => 4 } })->all],
+ [{ id => 1 }],
+ 'chaining remove_columns works';;
+
+ cmp_deeply
+ [
+ $rs->search({
+ id => { '!=' => 4 }
+ }, {
+ '+columns' => 'name'
+ })->all
+ ],
+ [{ name => 1, id => 1 }],
+ 'chaining and +columns works with remove_columns';
+}
+
+done_testing;
@@ -0,0 +1,29 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+my $expect = [ $rs->search(undef, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' })->all ];
+
+ok scalar @{$expect}, 'make sure test environment is not ruined forever';
+
+cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HashRefInflator works';
+
+cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HRI works';
+
+my $rs2 = $rs->search(undef);
+$rs2->result_class('::HRI');
+cmp_deeply [ $rs2->all ], $expect, '::HRI also works from result_class accessor';
+
+done_testing;
+
@@ -0,0 +1,32 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Exception;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+$schema->resultset('Gnarly')->update({ literature => 'boo.' });
+$schema->resultset('Gnarly')->create({ id => 4, name => 'fismboc' });
+my $rs = $schema->resultset('Gnarly')->search({ literature => 'boo.' });
+
+is($rs->count, 3, 'base rs has three results');
+
+my $rs2 = $schema->resultset('Gnarly')->search({ name => 'frew' });
+
+is($rs2->count, 1, 'rs2 has 1 result');
+my $rs3 = $schema->resultset('Gnarly')->search({ name => 'frioux' });
+is($rs3->count, 1, 'rs3 has 1 result');
+my $rs4 = $schema->resultset('Gnarly')->search({ name => 'fismboc' });
+is($rs4->count, 1, 'rs4 has 1 result');
+
+is($rs->search_or([$rs2, $rs3, $rs4])->count, 2, 'only two things are in all of rs and in any of rs2, rs3, or rs4');
+
+dies_ok { $rs->search_or([$schema->resultset('Bloaty')]) } 'or-ing differing ResultSets dies';
+
+done_testing;
@@ -0,0 +1,96 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+use Test::Exception;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo')->search({ id => 1 });
+my $rs2 = $schema->resultset('Foo')->search({ id => { '>=' => 3 } });
+my $rs3 = $schema->resultset('Foo')->search({ id => [ 1, 3 ] });
+
+cmp_deeply [ sort map $_->id, $rs2->union($rs2)->all ], [3, 4, 5],
+ 'union returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->union_all($rs2)->all ], [3, 3, 4, 4, 5, 5],
+ 'union returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->union($rs)->all ], [1, 3, 4, 5],
+ 'union returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->union($rs)->all ], [1, 3],
+ 'union returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->union_all($rs)->all ], [1, 1, 3],
+ 'union returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->intersect($rs)->all ], [],
+ 'intersect returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->intersect($rs)->all ], [1],
+ 'intersect returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs->intersect($rs3)->all ], [1],
+ 'intersect returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->intersect($rs3)->all ], [3],
+ 'intersect returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->intersect($rs2)->all ], [3],
+ 'intersect returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->except($rs)->all ], [3, 4, 5],
+ 'except returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs->except($rs2)->all ], [1],
+ 'except returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->except($rs)->all ], [3],
+ 'except returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs->except($rs3)->all ], [],
+ 'except returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs2->except($rs3)->all ], [4, 5],
+ 'except returns correct values';
+
+cmp_deeply [ sort map $_->id, $rs3->except($rs2)->all ], [1],
+ 'except returns correct values';
+
+dies_ok {
+ my $rs3 = $rs->search(undef, { columns => ['id'] });
+ $rs->union($rs3) ;
+} 'unioning differing ColSpecs dies';
+
+dies_ok {
+ $rs->union($rs->search_rs(undef, { result_class => 'DBIx::Class::ResultClass::HashRefInflator'})) ;
+} 'unioning with differing ResultClasses dies';
+
+dies_ok { $rs->union($schema->resultset('Bar')) } 'unioning differing ResultSets dies';
+
+{
+ my $rs3 = $rs->search(undef, {
+ columns => ['id'],
+ '+select' => [\'"foo" as station'],
+ '+as' => ['station'],
+ });
+ my $rs4 = $schema->resultset('Bar')->search(undef, {
+ columns => ['id'],
+ '+select' => [\'"bar" as station'],
+ '+as' => ['station'],
+ });
+ $rs3->result_class('DBIx::Class::ResultClass::HashRefInflator');
+ $rs4->result_class('DBIx::Class::ResultClass::HashRefInflator');
+ my $rs5 = $rs3->union($rs4);
+ lives_ok { [ $rs5->all ] }
+ q{unioning differing ResultSets does not die when you know what you're doing};
+}
+
+done_testing;
@@ -0,0 +1,22 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->search(undef, { columns => 'id' })->add_columns('bar_id')->all],
+ [$rs->search(undef, { columns => ['id', 'bar_id'] })->all],
+ 'add_columns works the same';
+
+done_testing;
+
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->columns(['bar_id'])->all],
+ [$rs->search(undef,{columns => ['bar_id']})->all],
+ 'columns works the same';
+
+done_testing;
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->distinct->all],
+ [$rs->search(undef,{distinct => 1})->all],
+ 'distinct works the same';
+
+done_testing;
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->group_by(['me.id'])->all],
+ [$rs->search(undef,{group_by => ['me.id']})->all],
+ 'group_by works the same';
+
+done_testing;
@@ -0,0 +1,23 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->hri->all],
+ [$rs->search(undef,{
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator'
+ })->all],
+ 'hri works the same';
+
+done_testing;
@@ -0,0 +1,18 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+ok($rs->has_rows, 'check rs has rows');
+
+done_testing;
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->rows(2)->all],
+ [$rs->limit(2)->all],
+ 'limit works the same';
+
+done_testing;
@@ -0,0 +1,37 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->limited_page(2, 3)->all],
+ [$rs->search({},{ page => 2, rows => 3 })->all],
+ 'limited_page works the same';
+
+cmp_deeply
+ [$rs->limited_page({ page => 2, rows => 3 })->all],
+ [$rs->search({},{ page => 2, rows => 3 })->all],
+ 'limited_page works the same';
+
+cmp_deeply
+ [$rs->limited_page({ page => 2 })->all],
+ [$rs->search({},{ page => 2 })->all],
+ 'limited_page works the same';
+
+cmp_deeply
+ [$rs->limited_page(2)->all],
+ [$rs->limited_page({ page => 2 })->all],
+ 'limited_page works the same';
+
+done_testing;
+
@@ -0,0 +1,26 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->order_by({ -desc => 'me.id' })->all],
+ [$rs->search({},{order_by => { -desc => 'me.id' }})->all],
+ 'hashref order_by works the same';
+
+cmp_deeply
+ [$rs->order_by(['me.id'])->all],
+ [$rs->search({},{order_by => { -asc => 'me.id' }})->all],
+ 'arrayref order_by works the same';
+
+done_testing;
@@ -0,0 +1,32 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+my %tests = (
+ 'id' => [{ -asc => 'me.id' }],
+ '!id' => [{ -desc => 'me.id' }],
+ 'id,!bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
+ 'id, !bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
+ 'id ,!bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
+ 'id , !bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
+);
+
+while (my ($order, $expect) = each(%tests)) {
+ cmp_deeply
+ [$rs->order_by($order)->all],
+ [$rs->search({},{order_by => $expect})->all],
+ "order_by works: $order";
+}
+
+done_testing;
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->prefetch('bar')->all],
+ [$rs->search(undef,{prefetch => 'bar' })->all],
+ 'prefetch works the same';
+
+done_testing;
@@ -0,0 +1,19 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset( 'Foo' )->search({ id => { '>' => 0 } });
+my $rs2 = $schema->resultset( 'Foo' )->search({ id => { '<' => 0 } });
+
+ok( $rs->results_exist, 'check rs has some results' );
+ok(!$rs2->results_exist, 'and check that rs has no results' );
+
+done_testing;
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $rs = $schema->resultset('Foo');
+
+cmp_deeply
+ [$rs->rows(2)->all],
+ [$rs->search({},{rows => 2})->all],
+ 'rows works the same';
+
+done_testing;
@@ -0,0 +1,19 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+cmp_deeply
+ $schema->resultset('Bar'),
+ $schema->resultset('Bar')->first->clean_rs;
+
+done_testing;
+
@@ -0,0 +1,68 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+{
+ my $bar_rs = TestSchema->resultset('Foo_Bar');
+
+ is $bar_rs->result_source->from, 'Foo_Bar', 'set table works';
+
+ relationships: {
+ my $bar_info = $bar_rs->result_source->relationship_info('bar');
+ is $bar_info->{class}, 'TestSchema::Result::Bar',
+ 'namespace correctly defaulted';
+
+ my $foo_info = $bar_rs->result_source->relationship_info('foo');
+ is $foo_info->{class}, 'TestSchema::Result::Foo',
+ 'namespace and method name correctly defaulted';
+ }
+
+ cmp_deeply [ $bar_rs->result_source->primary_columns ], [qw{foo_id bar_id}],
+ 'set primary keys works';
+
+ cmp_deeply $bar_rs->result_source->column_info('bar_id'), {
+ data_type => 'integer',
+ size => 12,
+ }, 'bar_id infers column info correctly';
+
+}
+
+{
+ relationships: {
+ my $g_rs = $schema->resultset('Gnarly');
+ my $s_rs = $schema->resultset('Station');
+ my $g_s_rs = $schema->resultset('Gnarly_Station');
+
+ cmp_deeply $g_s_rs->result_source->column_info('gnarly_id'), {
+ data_type => 'int',
+ }, 'gnarly_id defaults column info correctly';
+
+ is $s_rs->result_source->relationship_info('gnarly_stations')->{class},
+ 'TestSchema::Result::Gnarly_Station',
+ 'Left has_many defaulted correctly';
+
+ is $g_rs->result_source->relationship_info('gnarly_stations')->{class},
+ 'TestSchema::Result::Gnarly_Station',
+ 'Right has_many defaulted correctly';
+
+ cmp_deeply [ map $_->id, $s_rs->find(1)->gnarlies ],
+ [ 1, 2, 3 ],
+ 'Left many_to_many defaulted correctly';
+
+ cmp_deeply [ map $_->id, $g_rs->find(1)->stations ],
+ [ 1, 3 ],
+ 'Right many_to_many defaulted correctly';
+
+ }
+}
+
+done_testing;
@@ -0,0 +1,51 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+use Test::Exception;
+use List::Util 'first';
+
+use TestSchema;
+use B;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+# stolen from JSON::PP
+sub is_numeric {
+ my $value = shift;
+ my $b_obj = B::svref_2object(\$value);
+ my $flags = $b_obj->FLAGS;
+ return (( $flags & B::SVf_IOK or $flags & B::SVp_IOK
+ or $flags & B::SVf_NOK or $flags & B::SVp_NOK
+ ) and !($flags & B::SVf_POK ))
+}
+
+ok(is_numeric($schema->resultset('Foo')->first->bar_id),"bar_id has been 'numified' w/o is_numeric set");
+
+for (map $_->id, $schema->resultset('Foo')->all) {
+ ok(is_numeric($_), "id $_ has been 'numified'");
+}
+
+for (map +{$_->get_columns}, $schema->resultset('Foo')->all) {
+ ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
+}
+
+for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) {
+ ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
+}
+
+for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) {
+ ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
+}
+
+for ($schema->resultset('Foo')->search(undef, {
+ columns => { lol => 'id' },
+})->all) {
+ lives_ok { $_->get_column('lol') } "doesn't break when using columns";
+}
+
+done_testing;
@@ -0,0 +1,111 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+use Test::Exception;
+
+use TestSchema;
+use TestSchema::Result::Bar;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+throws_ok(
+ sub {
+ TestSchema::Result::Bar->after_column_change(
+ foo_id => {
+ method => sub { 1; }
+ },
+ id => {
+ method => sub { 1; }
+ },
+ );
+ },
+ qr/Invalid number of arguments\. One \$column => \$args pair at a time\./,
+);
+
+TestSchema::Result::Bar->after_column_change(
+ foo_id => {
+ method => sub { push @TestSchema::Result::Bar::events, [after_foo_id => $_[1], $_[2]] }
+ },
+);
+
+TestSchema::Result::Bar->after_column_change(
+ id => {
+ method => sub {
+ is($schema->storage->{transaction_depth}, 1, 'transactions turned on for id');
+ push @TestSchema::Result::Bar::events, [after_id => $_[1], $_[2]]
+ },
+ txn_wrap => 1,
+ },
+);
+
+my $another_txn_test = sub {
+ is($schema->storage->{transaction_depth}, 0, 'transactions turned off for non-txn')
+};
+
+TestSchema::Result::Bar->around_column_change(
+ foo_id => {
+ method => sub {
+ my ( $self, $fn, $old, $new ) = @_;
+ push @TestSchema::Result::Bar::events, [pre_around_foo_id => $old, $new];
+ $another_txn_test->();
+ $fn->();
+ push @TestSchema::Result::Bar::events, [post_around_foo_id => $old, $new];
+ },
+ },
+);
+
+my $first = $schema->resultset('Bar')->search(undef, { order_by => 'id' })->first;
+
+is($first->foo_id, 1, 'foo_id starts as 1');
+$first->foo_id(2);
+$first->update;
+is($first->foo_id, 2, 'foo_id is updated to 2');
+
+$another_txn_test = sub {};
+
+cmp_deeply([
+ [ 'before_foo_id', 1, 2 ], # comes from TestSchema::Result::Bar
+ [ 'pre_around_foo_id', 1, 2 ],
+ [ 'post_around_foo_id', 1, 2 ],
+ [ 'after_foo_id', 2, 2 ],
+], \@TestSchema::Result::Bar::events, 'subs fire in correct order and with correct args');
+
+@TestSchema::Result::Bar::events = ();
+
+$first->update({ foo_id => 1, id => 99 });
+
+is($first->foo_id, 1, 'foo_id is updated');
+is($first->id, 99, 'id is updated');
+cmp_deeply([
+ [ 'before_foo_id', 2, 1 ],
+ [ 'pre_around_foo_id', 2, 1 ],
+ [ 'post_around_foo_id', 2, 1 ],
+ [ 'after_id', undef, 99 ],
+ [ 'after_foo_id', 1, 1 ]
+], \@TestSchema::Result::Bar::events,
+ '... even with args passed to update');
+
+TestSchema::Result::Foo->after_column_change(
+ bar_id => {
+ method => sub { die },
+ txn_wrap => 1,
+ },
+);
+
+my $foo = $schema->resultset('Foo')->search(undef, { order_by => 'id' })->first;
+my $bar = $schema->resultset('Bar')->search( { id => { '!=' => $first->id } } )->first;
+dies_ok(
+ sub { $foo->update({ bar_id => $bar->id }); },
+ 'after_column_change method triggered when updating via foreign key column',
+);
+dies_ok(
+ sub { $foo->update({ bar => $first }); },
+ 'after_column_change method triggered when updating via relationship accessor',
+);
+
+done_testing;
@@ -0,0 +1,48 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $g = $schema->resultset('Gnarly')->search({
+ id => 1
+})->single;
+
+subtest 'unloaded data' => sub {
+ is($g->id_plus_one, 2, 'basic test');
+ is($g->id_plus_two, 3, 'slot and specified method');
+ is($g->id_plus_two, 3, 'slot and specified method(2)');
+};
+
+my $g2 = $schema->resultset('Gnarly')->with_id_plus_one->search({
+ id => 2
+})->single;
+
+subtest 'loaded data' => sub {
+ is($g2->id_plus_one, 3, 'basic');
+ is($g2->id_plus_two, 4, 'slot and specified method');
+};
+
+subtest 'copy result' => sub {
+ ok !$schema->resultset('Gnarly')->search({ id => 100 })->count,
+ 'will not accidentally collide';
+ ok my $g3 = $g->copy({ id => 100 }), 'Copied result';
+ isa_ok $g3, 'DBIx::Class::Row';
+ 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;
+
@@ -0,0 +1,35 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+$schema->resultset('Bloaty')->search({ id => 1000 })->delete;
+my $row = $schema->resultset('Bloaty')->create({
+ id => 1000,
+ name => 'woo',
+ literature => 'bored',
+ your_mom => 'hyuug',
+});
+
+$row->name('woot');
+
+$row->update({ literature => 'exciting' });
+
+cmp_deeply(
+ [{
+ name => 'woot',
+ literature => 'exciting',
+ }],
+ \@TestSchema::ResultSet::Bloaty::stuff,
+ 'update correctly proxied',
+);
+
+done_testing;
@@ -0,0 +1,20 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $r = $schema->resultset('Bar')->result_class;
+
+ok $r->has_relationship('foo'), 'has Foo';
+ok $r->has_relationship('foos'), 'has foos';
+
+done_testing;
+
@@ -0,0 +1,41 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+$schema->resultset('Foo_Bar')->delete;
+$schema->resultset('Foo_Bar')->populate([
+ [qw(foo_id bar_id)],
+ [1, 2],
+ [2, 1],
+ [4, 5],
+]);
+
+subtest 'single pk column' => sub {
+ for ($schema->resultset('Bar')->all) {
+ subtest 'Bar.id: ' . $_->id => sub {
+ is ($_->self_rs->count, 1, 'single row in self_rs');
+ is ($_->self_rs->single->id, $_->id, 'id matches');
+ };
+ }
+};
+
+subtest 'multi pk' => sub {
+ for ($schema->resultset('Foo_Bar')->all) {
+ subtest 'Foo_Bar: ' . $_->foo_id . ' ' . $_->bar_id => sub {
+ is ($_->self_rs->count, 1, 'single row in self_rs');
+ is ($_->self_rs->single->foo_id, $_->foo_id, 'foo_id matches');
+ is ($_->self_rs->single->bar_id, $_->bar_id, 'bar_id matches');
+ };
+ }
+};
+
+done_testing;
+
@@ -0,0 +1,24 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+my $first = $schema->resultset('Bar')->search(undef, { order_by => 'id' })->first;
+
+is($first->foo_id, 1, 'foo_id starts as 1');
+is($first->get_storage_value('foo_id'), 1, 'foo_id storage value starts as 1');
+$first->foo_id(2);
+is($first->foo_id, 2, 'foo_id changes to 2');
+is($first->get_storage_value('foo_id'), 1, 'foo_id storage value is still 1');
+$first->update;
+is($first->get_storage_value('foo_id'), 2, 'foo_id storage value is updated to 2');
+
+done_testing;
@@ -0,0 +1,29 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+
+namespacing: {
+ my $foo_rs = TestSchema->resultset('Foo');
+ my $bar_info = $foo_rs->result_source->relationship_info('bar');
+ is $bar_info->{class}, 'TestSchema::Result::Bar', 'namespacing seems to work';
+
+ my $bar_rs = TestSchema->resultset('Bar');
+ my $foo_info = $bar_rs->result_source->relationship_info('foo');
+ is $foo_info->{class}, 'TestSchema::Result::Foo', 'namespacing seems to work';
+}
+
+table: {
+ my $foo_rs = TestSchema->resultset('Foo');
+ is $foo_rs->result_source->from, 'Foo', 'set table works';
+
+ my $bar_rs = TestSchema->resultset('Bar');
+ is $bar_rs->result_source->from, 'Bar', 'set table works';
+}
+
+done_testing;
@@ -0,0 +1,80 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+my $schema = TestSchema->deploy_or_connect();
+$schema->prepopulate;
+
+SIMPLE_JSON: {
+ my $datas = [
+ map $_->TO_JSON,
+ $schema->resultset('Bar')->search(undef, { order_by => 'id' })->all
+ ];
+
+ cmp_deeply($datas, [{
+ id => 1,
+ foo_id => 1,
+ },{
+ id => 2,
+ foo_id => 2,
+ },{
+ id => 3,
+ foo_id => 3,
+ },{
+ id => 4,
+ foo_id => 4,
+ },{
+ id => 5,
+ foo_id => 5,
+ }], 'simple TO_JSON works');
+}
+
+MORE_COMPLEX_JSON: {
+ my $datas = [
+ map $_->TO_JSON,
+ $schema->resultset('Gnarly')->search(undef, { order_by => 'id' })->all
+ ];
+
+ cmp_deeply($datas, [{
+ id => 1,
+ name => 'frew',
+ your_mom => undef,
+ },{
+ id => 2,
+ name => 'frioux',
+ your_mom => undef,
+ },{
+ id => 3,
+ name => 'frooh',
+ your_mom => undef,
+ }], '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;
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+use DateTime;
+
+TestSchema->load_components('Helper::Schema::DateTime');
+my $schema = TestSchema->deploy_or_connect();
+
+isa_ok($schema->datetime_parser, 'DateTime::Format::SQLite');
+my $dt = DateTime->now;
+my $s = $schema->format_datetime($dt);
+is(
+ $schema->format_datetime($schema->parse_datetime($s)),
+ $schema->format_datetime($dt),
+ 'format_datetime and parse_datetime roundtrip',
+);
+
+done_testing;
@@ -0,0 +1,20 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Fatal;
+
+use TestSchema;
+
+my $schema = TestSchema->deploy_or_connect();
+
+like(
+ exception { $schema->resultset('foo_Bar') },
+ qr/\* Foo_Bar <--/,
+ 'found correct RS',
+);
+
+done_testing;
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+
+use TestSchema;
+
+TestSchema->load_components('Helper::Schema::GenerateSource');
+TestSchema->generate_source(PsychoKiller => 'Lolbot');
+
+my $class = TestSchema->class('PsychoKiller');
+ok($class, 'PsychoKiller gets registered');
+ok($class->isa('Lolbot'), 'PsychoKiller inherits from Lolbot');
+ok(ref($class) ne 'Lolbot', '... but PsychoKiller is not just a Lolbot');
+
+done_testing;
@@ -0,0 +1,85 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More;
+use Test::Deep;
+
+use TestSchema;
+
+subtest 'null_check_source_auto' => sub {
+ my $schema = TestSchema->deploy_or_connect();
+ $schema->prepopulate;
+
+ local $schema->source('Gnarly')->column_info('literature')->{is_nullable} = 0;
+ cmp_deeply [map +{ $_ => $schema->null_check_source_auto($_)->count }, sort $schema->sources], supersetof(
+ { Bar => 0 },
+ { Bloaty => 0 },
+ { Foo => 0 },
+ { Foo_Bar => 0 },
+ { Gnarly => 3 },
+ { Gnarly_Station => 0 },
+ { Station => 0 },
+ ), 'errors for Gnarly null_check_source';
+};
+
+subtest 'dub_check_source_auto' => sub {
+ my $schema = TestSchema->deploy_or_connect();
+ $schema->prepopulate;
+
+ $schema->resultset('Gnarly')->create({ id => 100 + $_, name => 'foo' }) for 1, 2;
+ $schema->resultset('Gnarly')->create({ id => 200 + $_, name => 'bar' }) for 1, 2;
+ $schema->source('Gnarly')->add_unique_constraint(['name']);
+
+ cmp_deeply [map {
+ my $source = $_;
+ my $constraints = $schema->dup_check_source_auto($source);
+ map {
+ my $constraint_name = $_;
+ +{ "$source $constraint_name" => $constraints->{$constraint_name}->count }
+ } sort keys %$constraints;
+ } grep { $_ ne 'Bloaty' } sort $schema->sources], supersetof(
+ { "Bar primary" => 0 },
+ { "Foo primary" => 0 },
+ { "Foo_Bar primary" => 0 },
+ { "Gnarly Gnarly_name" => 2 },
+ { "Gnarly primary" => 0 },
+ { "Gnarly_Station primary" => 0 },
+ { "Station primary" => 0 },
+ ), 'Gnarly_name duplicated twice';
+};
+
+subtest 'fk_check_source_auto' => sub {
+ my $schema = TestSchema->deploy_or_connect();
+ $schema->prepopulate;
+
+ $schema->resultset('Foo_Bar')->delete;
+ $schema->resultset('Foo_Bar')->create({
+ foo_id => 1010,
+ bar_id => 2020,
+ });
+ $schema->resultset('Foo_Bar')->create({
+ foo_id => 1111,
+ bar_id => 2222,
+ });
+
+ cmp_deeply [map {
+ my $source = $_;
+ my $constraints = $schema->fk_check_source_auto($source);
+ map {
+ my $fk_constraint_name = $_;
+ +{ "$source $fk_constraint_name" => $constraints->{$fk_constraint_name}->count }
+ } sort keys %$constraints;
+ } grep { $_ ne 'Bloaty' } sort $schema->sources], supersetof(
+ { "Bar foo" => 0 },
+ { "Foo bar" => 0 },
+ { "Foo_Bar bar" => 2 },
+ { "Foo_Bar foo" => 2 },
+ { "Gnarly_Station gnarly" => 0 },
+ { "Gnarly_Station station" => 0 },
+ ), 'foo and bar constraints broken';
+};
+
+done_testing;
@@ -5,7 +5,7 @@ use warnings;
# intentionally not using TestSchema::ResultSet
use parent 'DBIx::Class::ResultSet';
-__PACKAGE__->load_components(qw{ Helper::ResultSet::Me Helper::ResultSet::ResultClassDWIM Helper::ResultSet::CorrelateRelationship Helper::ResultSet::SearchOr Helper::ResultSet::NoColumns Helper::ResultSet::Explain });
+__PACKAGE__->load_components(qw{ Helper::ResultSet::Me Helper::ResultSet::ResultClassDWIM Helper::ResultSet::CorrelateRelationship Helper::ResultSet::SearchOr Helper::ResultSet::NoColumns Helper::ResultSet::Explain Helper::ResultSet::Errors });
sub with_id_plus_one {
my $self = shift;
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::MySQL
--- Created on Tue Nov 25 19:16:43 2014
+-- Created on Fri Feb 20 22:50:49 2015
--
SET foreign_key_checks=0;
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::Oracle
--- Created on Tue Nov 25 19:16:43 2014
+-- Created on Fri Feb 20 22:50:49 2015
--
--
-- Table: Gnarly
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
--- Created on Tue Nov 25 19:16:43 2014
+-- Created on Fri Feb 20 22:50:49 2015
--
--
-- Table: Gnarly.
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Generator::Role::DDL
--- Created on Tue Nov 25 19:16:43 2014
+-- Created on Fri Feb 20 22:50:49 2015
--
--
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Tue Nov 25 19:16:43 2014
+-- Created on Fri Feb 20 22:50:49 2015
--
BEGIN TRANSACTION;
@@ -1,56 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Gnarly')->search(undef, {
- '+columns' => {
- old_gnarlies => $schema->resultset('Gnarly')
- ->correlate('gnarly_stations')
- ->search({ station_id => { '>' => 2 }})
- ->count_rs->as_query,
- new_gnarlies => $schema->resultset('Gnarly')
- ->correlate('gnarly_stations')
- ->search({ station_id => { '<=' => 2 }})
- ->count_rs->as_query,
- },
- result_class => '::HRI',
-});
-
-cmp_deeply([$rs->all], [
- {
- id => 1,
- literature => undef,
- name => "frew",
- new_gnarlies => 1,
- old_gnarlies => 1,
- your_mom => undef
- },
- {
- id => 2,
- literature => undef,
- name => "frioux",
- new_gnarlies => 1,
- old_gnarlies => 0,
- your_mom => undef
- },
- {
- id => 3,
- literature => undef,
- name => "frooh",
- new_gnarlies => 1,
- old_gnarlies => 0,
- your_mom => undef
- }
-
-], 'relationship correlated correctly');
-
-done_testing;
@@ -1,78 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-use Test::More;
-use lib 't/lib';
-use A::ResultSet::DateMethods1;
-
-A::ResultSet::DateMethods1->run_tests(MSSQL => {
- engine => 'MSSQL',
- utc_now => 'GETUTCDATE()',
- stringified_date => '2014-02-08 04:43:00.000',
-
-
- storage_type => 'MSSQL',
-
- add_sql_prefix => \[ 'DATEADD(second, CAST(? AS int), [me].[a_date])', 1 ],
-
- add_sql_by_part_skip => {
- nanosecond => "doesn't work with DATETIME data type",
- },
-
- add_sql_by_part => {
- day => \[ 'DATEADD(dayofyear, CAST(? AS int), [a_date])', 1 ],
- hour => \[ 'DATEADD(hour, CAST(? AS int), [a_date])', 2 ],
- millisecond => \[ 'DATEADD(millisecond, CAST(? AS int), [a_date])', 7 ],
- minute => \[ 'DATEADD(minute, CAST(? AS int), [a_date])', 3 ],
- month => \[ 'DATEADD(month, CAST(? AS int), [a_date])', 4 ],
- nanosecond => \[ 'DATEADD(nanosecond, CAST(? AS int), [a_date])', 8 ],
- quarter => \[ 'DATEADD(quarter, CAST(? AS int), [a_date])', 9 ],
- second => \[ 'DATEADD(second, CAST(? AS int), [a_date])', 5 ],
- week => \[ 'DATEADD(week, CAST(? AS int), [a_date])', 10 ],
- year => \[ 'DATEADD(year, CAST(? AS int), [a_date])', 6 ],
- },
-
- add_sql_by_part_result => {
- day => '2012-12-13 00:00:00.000',
- hour => '2012-12-12 02:00:00.000',
- millisecond => '2012-12-12 00:00:00.007',
- minute => '2012-12-12 00:03:00.000',
- month => '2013-04-12 00:00:00.000',
- quarter => '2015-03-12 00:00:00.000',
- second => '2012-12-12 00:00:05.000',
- week => '2013-02-20 00:00:00.000',
- year => '2018-12-12 00:00:00.000',
- },
-
- pluck_sql_prefix => \[ q<DATEPART(second, [me].[a_date])> ],
-
- pluck_sql_by_part => {
- year => \[ 'DATEPART(year, [a_date])' ],
- quarter => \[ 'DATEPART(quarter, [a_date])' ],
- month => \[ 'DATEPART(month, [a_date])' ],
- day_of_year => \[ 'DATEPART(dayofyear, [a_date])' ],
- day_of_month => \[ 'DATEPART(day, [a_date])' ],
- week => \[ 'DATEPART(week, [a_date])' ],
- day_of_week => \[ 'DATEPART(ISO_WEEK, [a_date])' ],
- hour => \[ 'DATEPART(hour, [a_date])' ],
- minute => \[ 'DATEPART(minute, [a_date])' ],
- second => \[ 'DATEPART(second, [a_date])' ],
- millisecond => \[ 'DATEPART(millisecond, [a_date])' ],
- nanosecond => \[ 'DATEPART(nanosecond, [a_date])' ],
- non_iso_day_of_week => \[ 'DATEPART(weekday, [a_date])' ],
- timezone_as_minutes => \[ 'DATEPART(TZoffset, [a_date])' ],
- },
-
- pluck_sql_by_part_skip => {
- timezone_as_minutes => 'not supported by DateTime data type',
- },
-
- pluck_sql_by_part_result => {
- millisecond => 0,
- nanosecond => 0,
- non_iso_day_of_week => 2,
- },
-});
-
-done_testing;
@@ -1,77 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-use Test::More;
-use lib 't/lib';
-use A::ResultSet::DateMethods1;
-
-A::ResultSet::DateMethods1->run_tests(mysql => {
- engine => 'mysql',
- utc_now => 'UTC_TIMESTAMP()',
- stringified_date => '2014-02-08 04:43:00',
-
- storage_type => 'mysql',
-
- pluck_sql_prefix => \[ 'EXTRACT(SECOND FROM `me`.`a_date`)' ],
-
- pluck_sql_by_part => {
- microsecond => \[ 'EXTRACT(MICROSECOND FROM `a_date`)' ],
- second => \[ 'EXTRACT(SECOND FROM `a_date`)' ],
- minute => \[ 'EXTRACT(MINUTE FROM `a_date`)' ],
- hour => \[ 'EXTRACT(HOUR FROM `a_date`)' ],
- day_of_month => \[ 'EXTRACT(DAY FROM `a_date`)' ],
- week => \[ 'EXTRACT(WEEK FROM `a_date`)' ],
- month => \[ 'EXTRACT(MONTH FROM `a_date`)' ],
- quarter => \[ 'EXTRACT(QUARTER FROM `a_date`)' ],
- year => \[ 'EXTRACT(YEAR FROM `a_date`)' ],
- second_microsecond => \[ 'EXTRACT(SECOND_MICROSECOND FROM `a_date`)' ],
- minute_microsecond => \[ 'EXTRACT(MINUTE_MICROSECOND FROM `a_date`)' ],
- minute_second => \[ 'EXTRACT(MINUTE_SECOND FROM `a_date`)' ],
- hour_microsecond => \[ 'EXTRACT(HOUR_MICROSECOND FROM `a_date`)' ],
- hour_second => \[ 'EXTRACT(HOUR_SECOND FROM `a_date`)' ],
- hour_minute => \[ 'EXTRACT(HOUR_MINUTE FROM `a_date`)' ],
- day_microsecond => \[ 'EXTRACT(DAY_MICROSECOND FROM `a_date`)' ],
- day_second => \[ 'EXTRACT(DAY_SECOND FROM `a_date`)' ],
- day_minute => \[ 'EXTRACT(DAY_MINUTE FROM `a_date`)' ],
- day_hour => \[ 'EXTRACT(DAY_HOUR FROM `a_date`)' ],
- year_month => \[ 'EXTRACT(YEAR_MONTH FROM `a_date`)' ],
- },
-
- pluck_sql_by_part_result => {
- microsecond => 0,
- second_microsecond => '5000000',
- minute_microsecond => '405000000',
- minute_second => 405,
- hour_microsecond => '30405000000',
- hour_second => 30405,
- hour_minute => 304,
- day_microsecond => '2030405000000',
- day_second => '2030405',
- day_minute => 20304,
- day_hour => 203,
- year_month => '201201',
- },
-
- add_sql_prefix => \[ 'DATE_ADD(`me`.`a_date`, INTERVAL ? SECOND)', 1 ],
-
- add_sql_by_part => {
- day => \[ 'DATE_ADD(`a_date`, INTERVAL ? DAY)', 1 ],
- hour => \[ 'DATE_ADD(`a_date`, INTERVAL ? HOUR)', 2 ],
- microsecond => \[ 'DATE_ADD(`a_date`, INTERVAL ? MICROSECOND)', 7 ],
- minute => \[ 'DATE_ADD(`a_date`, INTERVAL ? MINUTE)', 3 ],
- month => \[ 'DATE_ADD(`a_date`, INTERVAL ? MONTH)', 4 ],
- quarter => \[ 'DATE_ADD(`a_date`, INTERVAL ? QUARTER)', 8 ],
- second => \[ 'DATE_ADD(`a_date`, INTERVAL ? SECOND)', 5 ],
- week => \[ 'DATE_ADD(`a_date`, INTERVAL ? WEEK)', 9 ],
- year => \[ 'DATE_ADD(`a_date`, INTERVAL ? YEAR)', 6 ],
- },
-
- add_sql_by_part_result => {
- microsecond => '2012-12-12 00:00:00.000007',
- quarter => '2014-12-12 00:00:00',
- week => '2013-02-13 00:00:00',
- },
-});
-
-done_testing;
@@ -1,62 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-use Test::More;
-use lib 't/lib';
-use A::ResultSet::DateMethods1;
-
-local $SIG{__WARN__} = sub {
- my $warning = shift;
-
- return if $warning =~
- m/DBIx::Class::Storage::DBI::Oracle.*sql_(?:limit_dialect|quote_char)/;
-
- print STDERR $warning;
-};
-
-A::ResultSet::DateMethods1->run_tests(Oracle => {
- on_connect_call => 'datetime_setup',
-
- engine => 'Oracle',
- utc_now => 'sys_extract_utc(SYSTIMESTAMP)',
- stringified_date => '2014-02-08 04:43:00',
-
- storage_type => 'Oracle',
-
- add_sql_prefix => \[
- '(TO_TIMESTAMP("me"."a_date") + NUMTODSINTERVAL(?, ?))', 1, 'SECOND',
- ],
-
- add_sql_by_part => {
- 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"))' ],
-
- pluck_sql_by_part => {
- 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 TO_TIMESTAMP("a_date"))' ],
- month => \[ 'EXTRACT(MONTH FROM TO_TIMESTAMP("a_date"))' ],
- year => \[ 'EXTRACT(YEAR FROM TO_TIMESTAMP("a_date"))' ],
- },
-});
-
-done_testing;
@@ -1,84 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-use Test::More;
-use lib 't/lib';
-use A::ResultSet::DateMethods1;
-
-A::ResultSet::DateMethods1->run_tests(Pg => {
- engine => 'Pg',
- utc_now => 'CURRENT_TIMESTAMP',
- stringified_date => '2014-02-08 04:43:00+0000',
-
- storage_type => 'Pg',
-
- add_sql_prefix => \[ q<("me"."a_date" + ? * interval '1 second')>, 1],
-
- add_sql_by_part => {
- century => \[ q<("a_date" + ? * interval '1 century')>, 7 ],
- day => \[ q<("a_date" + ? * interval '1 day')>, 1 ],
- decade => \[ q<("a_date" + ? * interval '1 decade')>, 8 ],
- hour => \[ q<("a_date" + ? * interval '1 hour')>, 2 ],
- microsecond => \[ q<("a_date" + ? * interval '1 microseconds')>, 9 ],
- millisecond => \[ q<("a_date" + ? * interval '1 milliseconds')>, 10 ],
- minute => \[ q<("a_date" + ? * interval '1 minute')>, 3 ],
- month => \[ q<("a_date" + ? * interval '1 month')>, 4 ],
- second => \[ q<("a_date" + ? * interval '1 second')>, 5 ],
- week => \[ q<("a_date" + ? * interval '1 week')>, 11 ],
- year => \[ q<("a_date" + ? * interval '1 year')>, 6 ],
- },
-
- add_sql_by_part_result => {
- century => '2712-12-12 00:00:00',
- decade => '2092-12-12 00:00:00',
- microsecond => '2012-12-12 00:00:00.000009',
- millisecond => '2012-12-12 00:00:00.01',
- week => '2013-02-27 00:00:00',
- },
-
- pluck_sql_prefix => \[ 'date_part(?, "me"."a_date")', 'second' ],
-
- pluck_sql_by_part => {
- century => \[ 'date_part(?, "a_date")', 'century' ],
- decade => \[ 'date_part(?, "a_date")', 'decade' ],
- day_of_month => \[ 'date_part(?, "a_date")', 'day' ],
- day_of_week => \[ 'date_part(?, "a_date")', 'dow' ],
- day_of_year => \[ 'date_part(?, "a_date")', 'doy' ],
- seconds_since_epoch => \[ 'date_part(?, "a_date")', 'epoch' ],
- hour => \[ 'date_part(?, "a_date")', 'hour' ],
- iso_day_of_week => \[ 'date_part(?, "a_date")', 'isodow' ],
- iso_year => \[ 'date_part(?, "a_date")', 'isoyear' ],
- microsecond => \[ 'date_part(?, "a_date")', 'microseconds' ],
- millenium => \[ 'date_part(?, "a_date")', 'millenium' ],
- millisecond => \[ 'date_part(?, "a_date")', 'milliseconds' ],
- minute => \[ 'date_part(?, "a_date")', 'minute' ],
- month => \[ 'date_part(?, "a_date")', 'month' ],
- quarter => \[ 'date_part(?, "a_date")', 'quarter' ],
- second => \[ 'date_part(?, "a_date")', 'second' ],
- timezone => \[ 'date_part(?, "a_date")', 'timezone' ],
- timezone_hour => \[ 'date_part(?, "a_date")', 'timezone_hour' ],
- timezone_minute => \[ 'date_part(?, "a_date")', 'timezone_minute' ],
- week => \[ 'date_part(?, "a_date")', 'week' ],
- year => \[ 'date_part(?, "a_date")', 'year' ],
- },
-
- pluck_sql_by_part_skip => {
- millenium => 'not supported by DateTime data type',
- timezone => 'not supported by DateTime data type',
- timezone_hour => 'not supported by DateTime data type',
- timezone_minute => 'not supported by DateTime data type',
- },
-
- pluck_sql_by_part_result => {
- century => 21,
- decade => 201,
- seconds_since_epoch => '1325473445',
- iso_day_of_week => 1,
- iso_year => 2012,
- microsecond => '5000000',
- millisecond => 5000,
- },
-});
-
-done_testing;
@@ -1,62 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-use Test::More;
-use lib 't/lib';
-use A::ResultSet::DateMethods1;
-
-A::ResultSet::DateMethods1->run_tests(SQLite => {
- engine => 'SQLite',
- utc_now => q<DATETIME('now')>,
- stringified_date => '2014-02-08 04:43:00',
-
- plucked_minute => '09',
- plucked_second => '08',
-
- connect_info => [ 'dbi:SQLite::memory:' ],
-
-
- add_sql_prefix => \[ 'DATETIME("me"."a_date", ? || ?)', 1, ' seconds' ],
-
- add_sql_by_part => {
- day => \[ 'DATETIME("a_date", ? || ?)', 1, ' days' ],
- hour => \[ 'DATETIME("a_date", ? || ?)', 2, ' hours' ],
- minute => \[ 'DATETIME("a_date", ? || ?)', 3, ' minutes' ],
- month => \[ 'DATETIME("a_date", ? || ?)', 4, ' months' ],
- second => \[ 'DATETIME("a_date", ? || ?)', 5, ' seconds' ],
- year => \[ 'DATETIME("a_date", ? || ?)', 6, ' years' ],
- },
-
- pluck_sql_prefix => \[ q<STRFTIME('%S', "me"."a_date")> ],
-
- pluck_sql_by_part => {
- year => \[ q<STRFTIME('%Y', "a_date")> ],
- month => \[ q<STRFTIME('%m', "a_date")> ],
- day_of_month => \[ q<STRFTIME('%d', "a_date")> ],
- hour => \[ q<STRFTIME('%H', "a_date")> ],
- day_of_year => \[ q<STRFTIME('%j', "a_date")> ],
- minute => \[ q<STRFTIME('%M', "a_date")> ],
- second => \[ q<STRFTIME('%S', "a_date")> ],
- day_of_week => \[ q<STRFTIME('%w', "a_date")> ],
- week => \[ q<STRFTIME('%W', "a_date")> ],
- julian_day => \[ q<STRFTIME('%J', "a_date")> ],
- seconds_since_epoch => \[ q<STRFTIME('%s', "a_date")> ],
- fractional_seconds => \[ q<STRFTIME('%f', "a_date")> ],
- },
-
- pluck_sql_by_part_result => {
- month => '01',
- day_of_month => '02',
- hour => '03',
- day_of_year => '002',
- minute => '04',
- second => '05',
- week => '01',
- julian_day => '2455928.627835648',
- seconds_since_epoch => '1325473445',
- fractional_seconds => '05.000',
- },
-});
-
-done_testing;
@@ -1,33 +0,0 @@
-#!perl
-
-use Test::Roo;
-use Test::Fatal;
-use Data::Dumper::Concise;
-
-use lib 't/lib';
-
-with 'A::Role::TestConnect';
-
-sub rs { shift->schema->resultset('Gnarly') }
-
-top_test basic => sub {
- my $self = shift;
- my $rs = $self->rs;
- SKIP: {
- skip 'cannot test without a connection', 1 unless $self->connected;
-
- my $s;
- my $e = exception { $s = $rs->explain };
- ok(!$e, 'valid SQL') or diag $e;
- note(Dumper($s)) if $s;
- }
-};
-
-run_me(SQLite => {
- engine => 'SQLite',
- connect_info => [ 'dbi:SQLite::memory:'],
-});
-run_me(Pg => { engine => 'Pg' });
-run_me(mysql => { engine => 'mysql' });
-
-done_testing;
@@ -1,28 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Fatal;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my ($rs) = $schema->resultset('Foo')->search;
-my ($rs2) = $schema->resultset('Bar')->search;
-my ($rs3) = $schema->resultset('Foo')->first->bars;
-my ($rs4) = $schema->resultset('Bar')->first->foos;
-
-isa_ok $rs, 'DBIx::Class::ResultSet';
-isa_ok $rs2, 'DBIx::Class::ResultSet';
-isa_ok $rs3, 'DBIx::Class::ResultSet';
-isa_ok $rs4, 'DBIx::Class::ResultSet';
-
-like(exception {
- $schema->resultset('Bar')->search
-}, qr/search is \*not\* a mutator/, 'correctly die in void ctx');
-
-done_testing;
@@ -1,18 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-
-my $rs = $schema->resultset('Gnarly');
-my $alias = $rs->current_source_alias;
-
-is $rs->me, "$alias.", 'me without args';
-is $rs->me('col'), "$alias.col", 'me with args';
-
-done_testing;
@@ -1,20 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Gnarly')->no_columns->search(undef, {
- result_class => '::HRI',
-});
-
-cmp_deeply([$rs->all], [ { }, { }, { } ], 'no columns selected');
-
-done_testing;
@@ -1,26 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Exception;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $row = $schema->resultset('Foo')->rand->single;
-# testing actual randomness is hard, and it's not actually random anyway,
-# so suck it.
-ok $row->id >= 1 && $row->id <= 5, 'row is one of the rows from the database';
-
-my @rows = map $_->id, $schema->resultset('Foo')->rand(4)->all;
-ok @rows == 4, 'correct amount of rows selected';
-for (@rows) {
- ok $_ >= 1 && $_ <= 5, 'row is one of the rows from the database';
-}
-
-
-done_testing;
@@ -1,68 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-use Test::Exception;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-RemoveColumns: {
- my $rs = $schema->resultset('Foo')->search({
- id => 1
- }, {
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
- 'remove_columns' => ['bar_id'],
- });
-
- cmp_deeply [$rs->all], [{ id => 1 }], 'remove_columns works';
-
- cmp_deeply
- [$rs->search({ id => { '!=' => 4 } })->all],
- [{ id => 1 }],
- 'chaining remove_columns works';;
-
- cmp_deeply
- [
- $rs->search({
- id => { '!=' => 4 }
- }, {
- '+columns' => 'bar_id'
- })->all
- ],
- [{ bar_id => 1, id => 1 }],
- 'chaining and +columns works with remove_columns';
-}
-
-AutoRemoveColumns: {
- my $rs = $schema->resultset('Bloaty')->search({
- id => 1
- }, {
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
- });
-
- cmp_deeply [$rs->all], [{ id => 1 }], 'remove_columns works';
-
- cmp_deeply
- [$rs->search({ id => { '!=' => 4 } })->all],
- [{ id => 1 }],
- 'chaining remove_columns works';;
-
- cmp_deeply
- [
- $rs->search({
- id => { '!=' => 4 }
- }, {
- '+columns' => 'name'
- })->all
- ],
- [{ name => 1, id => 1 }],
- 'chaining and +columns works with remove_columns';
-}
-
-done_testing;
@@ -1,29 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-my $expect = [ $rs->search(undef, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' })->all ];
-
-ok scalar @{$expect}, 'make sure test environment is not ruined forever';
-
-cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HashRefInflator works';
-
-cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HRI works';
-
-my $rs2 = $rs->search(undef);
-$rs2->result_class('::HRI');
-cmp_deeply [ $rs2->all ], $expect, '::HRI also works from result_class accessor';
-
-done_testing;
-
@@ -1,32 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Exception;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-$schema->resultset('Gnarly')->update({ literature => 'boo.' });
-$schema->resultset('Gnarly')->create({ id => 4, name => 'fismboc' });
-my $rs = $schema->resultset('Gnarly')->search({ literature => 'boo.' });
-
-is($rs->count, 3, 'base rs has three results');
-
-my $rs2 = $schema->resultset('Gnarly')->search({ name => 'frew' });
-
-is($rs2->count, 1, 'rs2 has 1 result');
-my $rs3 = $schema->resultset('Gnarly')->search({ name => 'frioux' });
-is($rs3->count, 1, 'rs3 has 1 result');
-my $rs4 = $schema->resultset('Gnarly')->search({ name => 'fismboc' });
-is($rs4->count, 1, 'rs4 has 1 result');
-
-is($rs->search_or([$rs2, $rs3, $rs4])->count, 2, 'only two things are in all of rs and in any of rs2, rs3, or rs4');
-
-dies_ok { $rs->search_or([$schema->resultset('Bloaty')]) } 'or-ing differing ResultSets dies';
-
-done_testing;
@@ -1,96 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-use Test::Exception;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo')->search({ id => 1 });
-my $rs2 = $schema->resultset('Foo')->search({ id => { '>=' => 3 } });
-my $rs3 = $schema->resultset('Foo')->search({ id => [ 1, 3 ] });
-
-cmp_deeply [ sort map $_->id, $rs2->union($rs2)->all ], [3, 4, 5],
- 'union returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->union_all($rs2)->all ], [3, 3, 4, 4, 5, 5],
- 'union returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->union($rs)->all ], [1, 3, 4, 5],
- 'union returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->union($rs)->all ], [1, 3],
- 'union returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->union_all($rs)->all ], [1, 1, 3],
- 'union returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->intersect($rs)->all ], [],
- 'intersect returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->intersect($rs)->all ], [1],
- 'intersect returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs->intersect($rs3)->all ], [1],
- 'intersect returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->intersect($rs3)->all ], [3],
- 'intersect returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->intersect($rs2)->all ], [3],
- 'intersect returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->except($rs)->all ], [3, 4, 5],
- 'except returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs->except($rs2)->all ], [1],
- 'except returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->except($rs)->all ], [3],
- 'except returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs->except($rs3)->all ], [],
- 'except returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs2->except($rs3)->all ], [4, 5],
- 'except returns correct values';
-
-cmp_deeply [ sort map $_->id, $rs3->except($rs2)->all ], [1],
- 'except returns correct values';
-
-dies_ok {
- my $rs3 = $rs->search(undef, { columns => ['id'] });
- $rs->union($rs3) ;
-} 'unioning differing ColSpecs dies';
-
-dies_ok {
- $rs->union($rs->search_rs(undef, { result_class => 'DBIx::Class::ResultClass::HashRefInflator'})) ;
-} 'unioning with differing ResultClasses dies';
-
-dies_ok { $rs->union($schema->resultset('Bar')) } 'unioning differing ResultSets dies';
-
-{
- my $rs3 = $rs->search(undef, {
- columns => ['id'],
- '+select' => [\'"foo" as station'],
- '+as' => ['station'],
- });
- my $rs4 = $schema->resultset('Bar')->search(undef, {
- columns => ['id'],
- '+select' => [\'"bar" as station'],
- '+as' => ['station'],
- });
- $rs3->result_class('DBIx::Class::ResultClass::HashRefInflator');
- $rs4->result_class('DBIx::Class::ResultClass::HashRefInflator');
- my $rs5 = $rs3->union($rs4);
- lives_ok { [ $rs5->all ] }
- q{unioning differing ResultSets does not die when you know what you're doing};
-}
-
-done_testing;
@@ -1,22 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->search(undef, { columns => 'id' })->add_columns('bar_id')->all],
- [$rs->search(undef, { columns => ['id', 'bar_id'] })->all],
- 'add_columns works the same';
-
-done_testing;
-
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->columns(['bar_id'])->all],
- [$rs->search(undef,{columns => ['bar_id']})->all],
- 'columns works the same';
-
-done_testing;
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->distinct->all],
- [$rs->search(undef,{distinct => 1})->all],
- 'distinct works the same';
-
-done_testing;
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->group_by(['me.id'])->all],
- [$rs->search(undef,{group_by => ['me.id']})->all],
- 'group_by works the same';
-
-done_testing;
@@ -1,18 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-ok($rs->has_rows, 'check rs has rows');
-
-done_testing;
@@ -1,23 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->hri->all],
- [$rs->search(undef,{
- result_class => 'DBIx::Class::ResultClass::HashRefInflator'
- })->all],
- 'hri works the same';
-
-done_testing;
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->rows(2)->all],
- [$rs->limit(2)->all],
- 'limit works the same';
-
-done_testing;
@@ -1,37 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->limited_page(2, 3)->all],
- [$rs->search({},{ page => 2, rows => 3 })->all],
- 'limited_page works the same';
-
-cmp_deeply
- [$rs->limited_page({ page => 2, rows => 3 })->all],
- [$rs->search({},{ page => 2, rows => 3 })->all],
- 'limited_page works the same';
-
-cmp_deeply
- [$rs->limited_page({ page => 2 })->all],
- [$rs->search({},{ page => 2 })->all],
- 'limited_page works the same';
-
-cmp_deeply
- [$rs->limited_page(2)->all],
- [$rs->limited_page({ page => 2 })->all],
- 'limited_page works the same';
-
-done_testing;
-
@@ -1,32 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-my %tests = (
- 'id' => [{ -asc => 'me.id' }],
- '!id' => [{ -desc => 'me.id' }],
- 'id,!bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
- 'id, !bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
- 'id ,!bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
- 'id , !bar_id' => [{ -asc => 'me.id' }, { -desc => 'bar_id' }],
-);
-
-while (my ($order, $expect) = each(%tests)) {
- cmp_deeply
- [$rs->order_by($order)->all],
- [$rs->search({},{order_by => $expect})->all],
- "order_by works: $order";
-}
-
-done_testing;
@@ -1,26 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->order_by({ -desc => 'me.id' })->all],
- [$rs->search({},{order_by => { -desc => 'me.id' }})->all],
- 'hashref order_by works the same';
-
-cmp_deeply
- [$rs->order_by(['me.id'])->all],
- [$rs->search({},{order_by => { -asc => 'me.id' }})->all],
- 'arrayref order_by works the same';
-
-done_testing;
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->prefetch('bar')->all],
- [$rs->search(undef,{prefetch => 'bar' })->all],
- 'prefetch works the same';
-
-done_testing;
@@ -1,19 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset( 'Foo' )->search({ id => { '>' => 0 } });
-my $rs2 = $schema->resultset( 'Foo' )->search({ id => { '<' => 0 } });
-
-ok( $rs->results_exist, 'check rs has some results' );
-ok(!$rs2->results_exist, 'and check that rs has no results' );
-
-done_testing;
@@ -1,21 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $rs = $schema->resultset('Foo');
-
-cmp_deeply
- [$rs->rows(2)->all],
- [$rs->search({},{rows => 2})->all],
- 'rows works the same';
-
-done_testing;
@@ -1,19 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-cmp_deeply
- $schema->resultset('Bar'),
- $schema->resultset('Bar')->first->clean_rs;
-
-done_testing;
-
@@ -1,68 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-{
- my $bar_rs = TestSchema->resultset('Foo_Bar');
-
- is $bar_rs->result_source->from, 'Foo_Bar', 'set table works';
-
- relationships: {
- my $bar_info = $bar_rs->result_source->relationship_info('bar');
- is $bar_info->{class}, 'TestSchema::Result::Bar',
- 'namespace correctly defaulted';
-
- my $foo_info = $bar_rs->result_source->relationship_info('foo');
- is $foo_info->{class}, 'TestSchema::Result::Foo',
- 'namespace and method name correctly defaulted';
- }
-
- cmp_deeply [ $bar_rs->result_source->primary_columns ], [qw{foo_id bar_id}],
- 'set primary keys works';
-
- cmp_deeply $bar_rs->result_source->column_info('bar_id'), {
- data_type => 'integer',
- size => 12,
- }, 'bar_id infers column info correctly';
-
-}
-
-{
- relationships: {
- my $g_rs = $schema->resultset('Gnarly');
- my $s_rs = $schema->resultset('Station');
- my $g_s_rs = $schema->resultset('Gnarly_Station');
-
- cmp_deeply $g_s_rs->result_source->column_info('gnarly_id'), {
- data_type => 'int',
- }, 'gnarly_id defaults column info correctly';
-
- is $s_rs->result_source->relationship_info('gnarly_stations')->{class},
- 'TestSchema::Result::Gnarly_Station',
- 'Left has_many defaulted correctly';
-
- is $g_rs->result_source->relationship_info('gnarly_stations')->{class},
- 'TestSchema::Result::Gnarly_Station',
- 'Right has_many defaulted correctly';
-
- cmp_deeply [ map $_->id, $s_rs->find(1)->gnarlies ],
- [ 1, 2, 3 ],
- 'Left many_to_many defaulted correctly';
-
- cmp_deeply [ map $_->id, $g_rs->find(1)->stations ],
- [ 1, 3 ],
- 'Right many_to_many defaulted correctly';
-
- }
-}
-
-done_testing;
@@ -1,51 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-use Test::Exception;
-use List::Util 'first';
-
-use TestSchema;
-use B;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-# stolen from JSON::PP
-sub is_numeric {
- my $value = shift;
- my $b_obj = B::svref_2object(\$value);
- my $flags = $b_obj->FLAGS;
- return (( $flags & B::SVf_IOK or $flags & B::SVp_IOK
- or $flags & B::SVf_NOK or $flags & B::SVp_NOK
- ) and !($flags & B::SVf_POK ))
-}
-
-ok(is_numeric($schema->resultset('Foo')->first->bar_id),"bar_id has been 'numified' w/o is_numeric set");
-
-for (map $_->id, $schema->resultset('Foo')->all) {
- ok(is_numeric($_), "id $_ has been 'numified'");
-}
-
-for (map +{$_->get_columns}, $schema->resultset('Foo')->all) {
- ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
-}
-
-for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) {
- ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
-}
-
-for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) {
- ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'");
-}
-
-for ($schema->resultset('Foo')->search(undef, {
- columns => { lol => 'id' },
-})->all) {
- lives_ok { $_->get_column('lol') } "doesn't break when using columns";
-}
-
-done_testing;
@@ -1,111 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-use Test::Exception;
-
-use TestSchema;
-use TestSchema::Result::Bar;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-throws_ok(
- sub {
- TestSchema::Result::Bar->after_column_change(
- foo_id => {
- method => sub { 1; }
- },
- id => {
- method => sub { 1; }
- },
- );
- },
- qr/Invalid number of arguments\. One \$column => \$args pair at a time\./,
-);
-
-TestSchema::Result::Bar->after_column_change(
- foo_id => {
- method => sub { push @TestSchema::Result::Bar::events, [after_foo_id => $_[1], $_[2]] }
- },
-);
-
-TestSchema::Result::Bar->after_column_change(
- id => {
- method => sub {
- is($schema->storage->{transaction_depth}, 1, 'transactions turned on for id');
- push @TestSchema::Result::Bar::events, [after_id => $_[1], $_[2]]
- },
- txn_wrap => 1,
- },
-);
-
-my $another_txn_test = sub {
- is($schema->storage->{transaction_depth}, 0, 'transactions turned off for non-txn')
-};
-
-TestSchema::Result::Bar->around_column_change(
- foo_id => {
- method => sub {
- my ( $self, $fn, $old, $new ) = @_;
- push @TestSchema::Result::Bar::events, [pre_around_foo_id => $old, $new];
- $another_txn_test->();
- $fn->();
- push @TestSchema::Result::Bar::events, [post_around_foo_id => $old, $new];
- },
- },
-);
-
-my $first = $schema->resultset('Bar')->search(undef, { order_by => 'id' })->first;
-
-is($first->foo_id, 1, 'foo_id starts as 1');
-$first->foo_id(2);
-$first->update;
-is($first->foo_id, 2, 'foo_id is updated to 2');
-
-$another_txn_test = sub {};
-
-cmp_deeply([
- [ 'before_foo_id', 1, 2 ], # comes from TestSchema::Result::Bar
- [ 'pre_around_foo_id', 1, 2 ],
- [ 'post_around_foo_id', 1, 2 ],
- [ 'after_foo_id', 2, 2 ],
-], \@TestSchema::Result::Bar::events, 'subs fire in correct order and with correct args');
-
-@TestSchema::Result::Bar::events = ();
-
-$first->update({ foo_id => 1, id => 99 });
-
-is($first->foo_id, 1, 'foo_id is updated');
-is($first->id, 99, 'id is updated');
-cmp_deeply([
- [ 'before_foo_id', 2, 1 ],
- [ 'pre_around_foo_id', 2, 1 ],
- [ 'post_around_foo_id', 2, 1 ],
- [ 'after_id', undef, 99 ],
- [ 'after_foo_id', 1, 1 ]
-], \@TestSchema::Result::Bar::events,
- '... even with args passed to update');
-
-TestSchema::Result::Foo->after_column_change(
- bar_id => {
- method => sub { die },
- txn_wrap => 1,
- },
-);
-
-my $foo = $schema->resultset('Foo')->search(undef, { order_by => 'id' })->first;
-my $bar = $schema->resultset('Bar')->search( { id => { '!=' => $first->id } } )->first;
-dies_ok(
- sub { $foo->update({ bar_id => $bar->id }); },
- 'after_column_change method triggered when updating via foreign key column',
-);
-dies_ok(
- sub { $foo->update({ bar => $first }); },
- 'after_column_change method triggered when updating via relationship accessor',
-);
-
-done_testing;
@@ -1,48 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $g = $schema->resultset('Gnarly')->search({
- id => 1
-})->single;
-
-subtest 'unloaded data' => sub {
- is($g->id_plus_one, 2, 'basic test');
- is($g->id_plus_two, 3, 'slot and specified method');
- is($g->id_plus_two, 3, 'slot and specified method(2)');
-};
-
-my $g2 = $schema->resultset('Gnarly')->with_id_plus_one->search({
- id => 2
-})->single;
-
-subtest 'loaded data' => sub {
- is($g2->id_plus_one, 3, 'basic');
- is($g2->id_plus_two, 4, 'slot and specified method');
-};
-
-subtest 'copy result' => sub {
- ok !$schema->resultset('Gnarly')->search({ id => 100 })->count,
- 'will not accidentally collide';
- ok my $g3 = $g->copy({ id => 100 }), 'Copied result';
- isa_ok $g3, 'DBIx::Class::Row';
- 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;
-
@@ -1,35 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-$schema->resultset('Bloaty')->search({ id => 1000 })->delete;
-my $row = $schema->resultset('Bloaty')->create({
- id => 1000,
- name => 'woo',
- literature => 'bored',
- your_mom => 'hyuug',
-});
-
-$row->name('woot');
-
-$row->update({ literature => 'exciting' });
-
-cmp_deeply(
- [{
- name => 'woot',
- literature => 'exciting',
- }],
- \@TestSchema::ResultSet::Bloaty::stuff,
- 'update correctly proxied',
-);
-
-done_testing;
@@ -1,20 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $r = $schema->resultset('Bar')->result_class;
-
-ok $r->has_relationship('foo'), 'has Foo';
-ok $r->has_relationship('foos'), 'has foos';
-
-done_testing;
-
@@ -1,41 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-$schema->resultset('Foo_Bar')->delete;
-$schema->resultset('Foo_Bar')->populate([
- [qw(foo_id bar_id)],
- [1, 2],
- [2, 1],
- [4, 5],
-]);
-
-subtest 'single pk column' => sub {
- for ($schema->resultset('Bar')->all) {
- subtest 'Bar.id: ' . $_->id => sub {
- is ($_->self_rs->count, 1, 'single row in self_rs');
- is ($_->self_rs->single->id, $_->id, 'id matches');
- };
- }
-};
-
-subtest 'multi pk' => sub {
- for ($schema->resultset('Foo_Bar')->all) {
- subtest 'Foo_Bar: ' . $_->foo_id . ' ' . $_->bar_id => sub {
- is ($_->self_rs->count, 1, 'single row in self_rs');
- is ($_->self_rs->single->foo_id, $_->foo_id, 'foo_id matches');
- is ($_->self_rs->single->bar_id, $_->bar_id, 'bar_id matches');
- };
- }
-};
-
-done_testing;
-
@@ -1,24 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-my $first = $schema->resultset('Bar')->search(undef, { order_by => 'id' })->first;
-
-is($first->foo_id, 1, 'foo_id starts as 1');
-is($first->get_storage_value('foo_id'), 1, 'foo_id storage value starts as 1');
-$first->foo_id(2);
-is($first->foo_id, 2, 'foo_id changes to 2');
-is($first->get_storage_value('foo_id'), 1, 'foo_id storage value is still 1');
-$first->update;
-is($first->get_storage_value('foo_id'), 2, 'foo_id storage value is updated to 2');
-
-done_testing;
@@ -1,29 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-
-namespacing: {
- my $foo_rs = TestSchema->resultset('Foo');
- my $bar_info = $foo_rs->result_source->relationship_info('bar');
- is $bar_info->{class}, 'TestSchema::Result::Bar', 'namespacing seems to work';
-
- my $bar_rs = TestSchema->resultset('Bar');
- my $foo_info = $bar_rs->result_source->relationship_info('foo');
- is $foo_info->{class}, 'TestSchema::Result::Foo', 'namespacing seems to work';
-}
-
-table: {
- my $foo_rs = TestSchema->resultset('Foo');
- is $foo_rs->result_source->from, 'Foo', 'set table works';
-
- my $bar_rs = TestSchema->resultset('Bar');
- is $bar_rs->result_source->from, 'Bar', 'set table works';
-}
-
-done_testing;
@@ -1,80 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-my $schema = TestSchema->deploy_or_connect();
-$schema->prepopulate;
-
-SIMPLE_JSON: {
- my $datas = [
- map $_->TO_JSON,
- $schema->resultset('Bar')->search(undef, { order_by => 'id' })->all
- ];
-
- cmp_deeply($datas, [{
- id => 1,
- foo_id => 1,
- },{
- id => 2,
- foo_id => 2,
- },{
- id => 3,
- foo_id => 3,
- },{
- id => 4,
- foo_id => 4,
- },{
- id => 5,
- foo_id => 5,
- }], 'simple TO_JSON works');
-}
-
-MORE_COMPLEX_JSON: {
- my $datas = [
- map $_->TO_JSON,
- $schema->resultset('Gnarly')->search(undef, { order_by => 'id' })->all
- ];
-
- cmp_deeply($datas, [{
- id => 1,
- name => 'frew',
- your_mom => undef,
- },{
- id => 2,
- name => 'frioux',
- your_mom => undef,
- },{
- id => 3,
- name => 'frooh',
- your_mom => undef,
- }], '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;
@@ -1,22 +0,0 @@
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-use DateTime;
-
-TestSchema->load_components('Helper::Schema::DateTime');
-my $schema = TestSchema->deploy_or_connect();
-
-isa_ok($schema->datetime_parser, 'DateTime::Format::SQLite');
-my $dt = DateTime->now;
-my $s = $schema->format_datetime($dt);
-is(
- $schema->format_datetime($schema->parse_datetime($s)),
- $schema->format_datetime($dt),
- 'format_datetime and parse_datetime roundtrip',
-);
-
-done_testing;
@@ -1,20 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Fatal;
-
-use TestSchema;
-
-my $schema = TestSchema->deploy_or_connect();
-
-like(
- exception { $schema->resultset('foo_Bar') },
- qr/\* Foo_Bar <--/,
- 'found correct RS',
-);
-
-done_testing;
@@ -1,17 +0,0 @@
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-
-use TestSchema;
-
-TestSchema->load_components('Helper::Schema::GenerateSource');
-TestSchema->generate_source(PsychoKiller => 'Lolbot');
-
-my $class = TestSchema->class('PsychoKiller');
-ok($class, 'PsychoKiller gets registered');
-ok($class->isa('Lolbot'), 'PsychoKiller inherits from Lolbot');
-ok(ref($class) ne 'Lolbot', '... but PsychoKiller is not just a Lolbot');
-
-done_testing;
@@ -1,85 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use lib 't/lib';
-use Test::More;
-use Test::Deep;
-
-use TestSchema;
-
-subtest 'null_check_source_auto' => sub {
- my $schema = TestSchema->deploy_or_connect();
- $schema->prepopulate;
-
- local $schema->source('Gnarly')->column_info('literature')->{is_nullable} = 0;
- cmp_deeply [map +{ $_ => $schema->null_check_source_auto($_)->count }, sort $schema->sources], supersetof(
- { Bar => 0 },
- { Bloaty => 0 },
- { Foo => 0 },
- { Foo_Bar => 0 },
- { Gnarly => 3 },
- { Gnarly_Station => 0 },
- { Station => 0 },
- ), 'errors for Gnarly null_check_source';
-};
-
-subtest 'dub_check_source_auto' => sub {
- my $schema = TestSchema->deploy_or_connect();
- $schema->prepopulate;
-
- $schema->resultset('Gnarly')->create({ id => 100 + $_, name => 'foo' }) for 1, 2;
- $schema->resultset('Gnarly')->create({ id => 200 + $_, name => 'bar' }) for 1, 2;
- $schema->source('Gnarly')->add_unique_constraint(['name']);
-
- cmp_deeply [map {
- my $source = $_;
- my $constraints = $schema->dup_check_source_auto($source);
- map {
- my $constraint_name = $_;
- +{ "$source $constraint_name" => $constraints->{$constraint_name}->count }
- } sort keys %$constraints;
- } grep { $_ ne 'Bloaty' } sort $schema->sources], supersetof(
- { "Bar primary" => 0 },
- { "Foo primary" => 0 },
- { "Foo_Bar primary" => 0 },
- { "Gnarly Gnarly_name" => 2 },
- { "Gnarly primary" => 0 },
- { "Gnarly_Station primary" => 0 },
- { "Station primary" => 0 },
- ), 'Gnarly_name duplicated twice';
-};
-
-subtest 'fk_check_source_auto' => sub {
- my $schema = TestSchema->deploy_or_connect();
- $schema->prepopulate;
-
- $schema->resultset('Foo_Bar')->delete;
- $schema->resultset('Foo_Bar')->create({
- foo_id => 1010,
- bar_id => 2020,
- });
- $schema->resultset('Foo_Bar')->create({
- foo_id => 1111,
- bar_id => 2222,
- });
-
- cmp_deeply [map {
- my $source = $_;
- my $constraints = $schema->fk_check_source_auto($source);
- map {
- my $fk_constraint_name = $_;
- +{ "$source $fk_constraint_name" => $constraints->{$fk_constraint_name}->count }
- } sort keys %$constraints;
- } grep { $_ ne 'Bloaty' } sort $schema->sources], supersetof(
- { "Bar foo" => 0 },
- { "Foo bar" => 0 },
- { "Foo_Bar bar" => 2 },
- { "Foo_Bar foo" => 2 },
- { "Gnarly_Station gnarly" => 0 },
- { "Gnarly_Station station" => 0 },
- ), 'foo and bar constraints broken';
-};
-
-done_testing;