* Fixes
- Fix SkipFirst and FirstSkip limit dialects (Informix and Firebird)
+ * Misc
+ - Codebase is now trailing-whitespace-free
+
0.08196 2011-11-29 05:35 (UTC)
* Fixes
- Fix tests for DBD::SQLite >= 1.34.
$spec = Getopt::Long::Descriptive->_strip_assignment($spec);
$string .= "=item " . join " or ", map { length > 1 ? "B<--$_>" : "B<-$_>" }
- split /\|/, $spec;
+ split /\|/, $spec;
$string .= "\n\n$desc\n\n=cut\n\n";
}
=head1 DESCRIPTION
DBIx::Class features a fully featured compatibility layer with L<Class::DBI>
-and some common plugins to ease transition for existing CDBI users.
+and some common plugins to ease transition for existing CDBI users.
This is not a wrapper or subclass of DBIx::Class but rather a series of plugins. The result being that even though you're using the Class::DBI emulation layer you are still getting DBIx::Class objects. You can use all DBIx::Class features and methods via CDBICompat. This allows you to take advantage of DBIx::Class features without having to rewrite your CDBI code.
=head2 Choosing Features
In fact, this class is just a recipe containing all the features emulated.
-If you like, you can choose which features to emulate by building your
+If you like, you can choose which features to emulate by building your
own class and loading it like this:
package My::DB;
sub accessor_name_for {
my ($class, $column) = @_;
- if ($class->can('accessor_name')) {
- return $class->accessor_name($column)
+ if ($class->can('accessor_name')) {
+ return $class->accessor_name($column)
}
return $column;
sub mutator_name_for {
my ($class, $column) = @_;
- if ($class->can('mutator_name')) {
- return $class->mutator_name($column)
+ if ($class->can('mutator_name')) {
+ return $class->mutator_name($column)
}
return $column;
}
-# Emulate that CDBI throws out all changed columns and reloads them on
+# Emulate that CDBI throws out all changed columns and reloads them on
# request in case the database modifies the new value (say, via a trigger)
sub update {
my $self = shift;
if ($result_class ne $class) { # new class
# Give this new class its own source and register it.
- $source = $source->new({
- %$source,
+ $source = $source->new({
+ %$source,
source_name => $class,
result_class => $class
} );
return unless defined($info->{is_file_column});
$self->inflate_column($column => {
- inflate => sub {
+ inflate => sub {
my ($value, $obj) = @_;
$obj->_inflate_file_column($column, $value);
},
data_type => "varchar",
is_file_column => 1,
file_column_path =>'/tmp/uploaded_files',
- # or for a Catalyst application
+ # or for a Catalyst application
# file_column_path => MyApp->path_to('root','static','files'),
default_value => undef,
is_nullable => 1,
FileColumn requires a hash that contains L<IO::File> as handle and the file's
name as name.
- my $entry = $c->model('MyAppDB::Articles')->create({
+ my $entry = $c->model('MyAppDB::Articles')->create({
subject => 'blah',
- filename => {
- handle => $c->req->upload('myupload')->fh,
- filename => $c->req->upload('myupload')->basename
+ filename => {
+ handle => $c->req->upload('myupload')->fh,
+ filename => $c->req->upload('myupload')->basename
},
body => '....'
});
And Place the following in your TT template
Article Subject: [% entry.subject %]
- Uploaded File:
+ Uploaded File:
<a href="/static/files/[% entry.id %]/[% entry.filename.filename %]">File</a>
Body: [% entry.body %]
-=head1 NAME
+=head1 NAME
DBIx::Class::Manual - Index of the Manual
=head1 DESCRIPTION
-This is the L<DBIx::Class> users manual. DBIx::Class is a SQL->OOP mapper.
+This is the L<DBIx::Class> users manual. DBIx::Class is a SQL->OOP mapper.
This means that it can represent your SQL tables as perl classes, and give
you convenient accessors and methods for retrieving and updating information
from your SQL database.
=head2 L<DBIx::Class::Manual::Intro>
-Beginner guide to using DBIx::Class.
+Beginner guide to using DBIx::Class.
=head2 L<DBIx::Class::Manual::Example>
=head2 L<DBIx::Class::Manual::Component>
-Existing components, and documentation and example on how to
+Existing components, and documentation and example on how to
develop new ones.
=cut
=item .. define a relationship bridge across an intermediate table? (many-to-many)
-The term 'relationship' is used loosely with many_to_many as it is not considered a
-relationship in the fullest sense. For more info, read the documentation on L<DBIx::Class::Relationship/many_to_many>.
+The term 'relationship' is used loosely with many_to_many as it is not considered a
+relationship in the fullest sense. For more info, read the documentation on L<DBIx::Class::Relationship/many_to_many>.
=item .. stop DBIx::Class from attempting to cascade deletes on my has_many and might_have relationships?
=head2 Custom methods in Result classes
-You can add custom methods that do arbitrary things, even to unrelated tables.
-For example, to provide a C<< $book->foo() >> method which searches the
+You can add custom methods that do arbitrary things, even to unrelated tables.
+For example, to provide a C<< $book->foo() >> method which searches the
cd table, you'd could add this to Book.pm:
sub foo {
write your own methods, you can.
For example, to provide a C<< $book->foo() >> method to manually implement
-what create_related() from L<DBIx::Class::Relationship::Base> does, you could
+what create_related() from L<DBIx::Class::Relationship::Base> does, you could
add this to Book.pm:
sub foo {
package Your::Schema::Group;
use Class::Method::Modifiers;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
# if the server group is a "super group", then return all servers
# otherwise return only servers that belongs to the given group
around 'servers' => sub {
package Your::Schema::Group;
use Method::Signatures::Simple;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
# The method keyword automatically injects the annoying my $self = shift; for you.
method servers {
return $self->result_source->schema->resultset('Server')->search({ ... });
package Your::Schema::Group;
use Sub::Name;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
*servers = subname servers => sub {
my $self = shift;
return $self->result_source->schema->resultset('Server')->search({ ... });
};
-
+
=back
=head2 Notes for CDBI users
=head2 Relationship bridge
A relationship bridge, such as C<many_to_many> defines an accessor to
-retrieve row contents across multiple relationships.
+retrieve row contents across multiple relationships.
The difference between a bridge and a relationship is, that the bridge
cannot be used to C<join> tables in a C<search>, instead its component
__PACKAGE__->position_column('rank');
Ordered will refer to a field called 'position' unless otherwise directed. Here you are defining
-the ordering field to be named 'rank'. (NOTE: Insert errors may occur if you use the Ordered
+the ordering field to be named 'rank'. (NOTE: Insert errors may occur if you use the Ordered
component, but have not defined a position column or have a 'position' field in your row.)
Set the table for your class:
-=head1 NAME
+=head1 NAME
DBIx::Class::Manual::Joining - Manual on joining tables with DBIx::Class
output. This is better solved by storing that field in a separate
table which you only join to when needed.
-To fetch an incomplete related object, supply the dotted notation to the '+as' attribute:
+To fetch an incomplete related object, supply the dotted notation to the '+as' attribute:
$schema->resultset('CD')->search(
{ 'Title' => 'Funky CD',
},
{ join => 'tracks',
'+select' => ['tracks.Name'],
- '+as' => ['tracks.Name'],
+ '+as' => ['tracks.Name'],
order_by => ['tracks.id'],
}
);
To perform joins using relations of the tables you are joining to, use
a hashref to indicate the join depth. This can theoretically go as
-deep as you like (warning: contrived examples!):
+deep as you like (warning: contrived examples!):
join => { room => { table => 'leg' } }
To join two relations at the same level, use an arrayref instead:
- join => { room => [ 'chair', 'table' ] }
+ join => { room => [ 'chair', 'table' ] }
Or combine the two:
=item *
-| - Alternate argument content types.
+| - Alternate argument content types.
At least one of these must be supplied unless the argument is also
marked optional.
There's likely a syntax error in the table class referred to elsewhere
in this error message. In particular make sure that the package
-declaration is correct. For example, for a schema C< MySchema >
+declaration is correct. For example, for a schema C< MySchema >
you need to specify a fully qualified namespace: C< package MySchema::MyTable; >.
=head2 syntax error at or near "<something>" ...
=head2 Excessive Memory Allocation with TEXT/BLOB/etc. Columns and Large LongReadLen
-It has been observed, using L<DBD::ODBC>, that creating a L<DBIx::Class::Row>
-object which includes a column of data type TEXT/BLOB/etc. will allocate
-LongReadLen bytes. This allocation does not leak, but if LongReadLen
-is large in size, and many such row objects are created, e.g. as the
-output of a ResultSet query, the memory footprint of the Perl interpreter
+It has been observed, using L<DBD::ODBC>, that creating a L<DBIx::Class::Row>
+object which includes a column of data type TEXT/BLOB/etc. will allocate
+LongReadLen bytes. This allocation does not leak, but if LongReadLen
+is large in size, and many such row objects are created, e.g. as the
+output of a ResultSet query, the memory footprint of the Perl interpreter
can grow very large.
The solution is to use the smallest practical value for LongReadLen.
test_eol => {
req => {
- 'Test::EOL' => '0.6',
+ 'Test::EOL' => '1.0',
},
},
title => 'Informix support',
desc => 'Modules required to connect to Informix',
},
- },
+ },
rdbms_sqlanywhere => {
req => {
title => 'SQLAnywhere support',
desc => 'Modules required to connect to SQLAnywhere',
},
- },
+ },
rdbms_sqlanywhere_odbc => {
req => {
title => 'SQLAnywhere support via DBD::ODBC',
desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
},
- },
+ },
rdbms_firebird => {
req => {
title => 'Firebird support',
desc => 'Modules required to connect to Firebird',
},
- },
+ },
rdbms_firebird_interbase => {
req => {
title => 'Firebird support via DBD::InterBase',
desc => 'Modules required to connect to Firebird via DBD::InterBase',
},
- },
+ },
rdbms_firebird_odbc => {
req => {
title => 'Firebird support via DBD::ODBC',
desc => 'Modules required to connect to Firebird via DBD::ODBC',
},
- },
+ },
# the order does matter because the rdbms support group might require
# a different version that the test group
position INTEGER NOT NULL
);
-Optionally, add one or more columns to specify groupings, allowing you
+Optionally, add one or more columns to specify groupings, allowing you
to maintain independent ordered lists within one table:
CREATE TABLE items (
other_group_id INTEGER NOT NULL
);
-In your Schema or DB class add "Ordered" to the top
+In your Schema or DB class add "Ordered" to the top
of the component list.
__PACKAGE__->load_components(qw( Ordered ... ));
-Specify the column that stores the position number for
+Specify the column that stores the position number for
each row.
package My::Item;
=head1 DESCRIPTION
-This module provides a simple interface for modifying the ordered
+This module provides a simple interface for modifying the ordered
position of DBIx::Class objects.
=head1 AUTO UPDATE
-All of the move_* methods automatically update the rows involved in
-the query. This is not configurable and is due to the fact that if you
+All of the move_* methods automatically update the rows involved in
+the query. This is not configurable and is due to the fact that if you
move a record it always causes other records in the list to be updated.
=head1 METHODS
__PACKAGE__->position_column('position');
-Sets and retrieves the name of the column that stores the
+Sets and retrieves the name of the column that stores the
positional value of each record. Defaults to "position".
=cut
__PACKAGE__->grouping_column('group_id');
-This method specifies a column to limit all queries in
-this module by. This effectively allows you to have multiple
+This method specifies a column to limit all queries in
+this module by. This effectively allows you to have multiple
ordered lists within the same table.
=cut
my $sibling = $item->first_sibling();
-Returns the first sibling object, or 0 if the first sibling
+Returns the first sibling object, or 0 if the first sibling
is this sibling.
=cut
my $sibling = $item->last_sibling();
-Returns the last sibling, or 0 if the last sibling is this
+Returns the last sibling, or 0 if the last sibling is this
sibling.
=cut
1 is returned on success, and 0 is returned if the object is
already at the specified position of the specified group.
-$group may be specified as a single scalar if only one
+$group may be specified as a single scalar if only one
grouping column is in use, or as a hashref of column => value pairs
if multiple grouping columns are in use.
=head2 insert
-Overrides the DBIC insert() method by providing a default
-position number. The default will be the number of rows in
+Overrides the DBIC insert() method by providing a default
+position number. The default will be the number of rows in
the table +1, thus positioning the new record at the last position.
=cut
if (
$pos_is_pk
or
- first { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) )
+ first { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) )
) {
my $cursor = $shift_rs->search (
{}, { order_by => { "-$ord", $position_column }, select => [$position_column, @pcols] }
=head1 PRIVATE METHODS
-These methods are used internally. You should never have the
+These methods are used internally. You should never have the
need to use them.
=head2 _group_rs
=head2 _grouping_clause
This method returns one or more name=>value pairs for limiting a search
-by the grouping column(s). If the grouping column is not defined then
+by the grouping column(s). If the grouping column is not defined then
this will return an empty list.
=cut
=head2 Multiple Moves
-Be careful when issuing move_* methods to multiple objects. If
-you've pre-loaded the objects then when you move one of the objects
-the position of the other object will not reflect their new value
+Be careful when issuing move_* methods to multiple objects. If
+you've pre-loaded the objects then when you move one of the objects
+the position of the other object will not reflect their new value
until you reload them from the database - see
L<DBIx::Class::Row/discard_changes>.
-There are times when you will want to move objects as groups, such
-as changing the parent of several objects at once - this directly
-conflicts with this problem. One solution is for us to write a
-ResultSet class that supports a parent() method, for example. Another
-solution is to somehow automagically modify the objects that exist
+There are times when you will want to move objects as groups, such
+as changing the parent of several objects at once - this directly
+conflicts with this problem. One solution is for us to write a
+ResultSet class that supports a parent() method, for example. Another
+solution is to somehow automagically modify the objects that exist
in the current object's result set to have the new position value.
=head2 Default Values
=back
# in a Book class (where Author has many Books)
- My::DBIC::Schema::Book->belongs_to(
- author =>
- 'My::DBIC::Schema::Author',
+ My::DBIC::Schema::Book->belongs_to(
+ author =>
+ 'My::DBIC::Schema::Author',
'author_id'
);
My::DBIC::Schema::Book->belongs_to(
author =>
'My::DBIC::Schema::Author',
- { 'foreign.author_id' => 'self.author_id' }
+ { 'foreign.author_id' => 'self.author_id' }
);
# OR (similar result but uglier accessor name)
- My::DBIC::Schema::Book->belongs_to(
+ My::DBIC::Schema::Book->belongs_to(
author_id =>
'My::DBIC::Schema::Author'
);
# in a Book class (where Author has_many Books)
__PACKAGE__->belongs_to(
- author =>
+ author =>
'My::DBIC::Schema::Author',
- 'author',
+ 'author',
{ join_type => 'left' }
);
Creates a one-to-many relationship where the foreign class refers to
this class's primary key. This relationship refers to zero or more
-records in the foreign table (e.g. a C<LEFT JOIN>). This relationship
+records in the foreign table (e.g. a C<LEFT JOIN>). This relationship
defaults to using the end of this classes namespace as the foreign key
in C<$related_class> to resolve the join, unless C<$their_fk_column>
specifies the foreign key column in C<$related_class> or C<cond>
# in an Author class (where Author has_many Books)
# assuming related class is storing our PK in "author_id"
My::DBIC::Schema::Author->has_many(
- books =>
- 'My::DBIC::Schema::Book',
+ books =>
+ 'My::DBIC::Schema::Book',
'author_id'
);
# OR (same result)
My::DBIC::Schema::Author->has_many(
- books =>
- 'My::DBIC::Schema::Book',
+ books =>
+ 'My::DBIC::Schema::Book',
{ 'foreign.author_id' => 'self.id' },
);
# OR (similar result, assuming related_class is storing our PK, in "author")
# (the "author" is guessed at from "Author" in the class namespace)
My::DBIC::Schema::Author->has_many(
- books =>
- 'My::DBIC::Schema::Book',
+ books =>
+ 'My::DBIC::Schema::Book',
);
# Usage
- # resultset of Books belonging to author
+ # resultset of Books belonging to author
my $booklist = $author->books;
# resultset of Books belonging to author, restricted by author name
# Every book has exactly one ISBN
My::DBIC::Schema::Book->has_one(
- isbn =>
+ isbn =>
'My::DBIC::Schema::ISBN',
'book_id',
);
# OR (same result, assuming related_class stores our PK)
My::DBIC::Schema::Book->has_one(
- isbn =>
+ isbn =>
'My::DBIC::Schema::ISBN',
);
# OR (same result)
My::DBIC::Schema::Book->has_one(
- isbn =>
+ isbn =>
'My::DBIC::Schema::ISBN',
{ 'foreign.book_id' => 'self.id' },
);
C<many_to_many> is not strictly a relationship in its own right. Instead, it is
a bridge between two resultsets which provide the same kind of convenience
-accessors as true relationships provide. Although the accessor will return a
-resultset or collection of objects just like has_many does, you cannot call
+accessors as true relationships provide. Although the accessor will return a
+resultset or collection of objects just like has_many does, you cannot call
C<related_resultset> and similar methods which operate on true relationships.
=over
use warnings;
use Sub::Name ();
-our %_pod_inherit_config =
+our %_pod_inherit_config =
(
class_map => { 'DBIx::Class::Relationship::Accessor' => 'DBIx::Class::Relationship' }
);
clause of the C<JOIN> statement associated with this relationship.
While every coderef-based condition must return a valid C<ON> clause, it may
-elect to additionally return a simplified join-free condition hashref when
+elect to additionally return a simplified join-free condition hashref when
invoked as C<< $row_object->relationship >>, as opposed to
C<< $rs->related_resultset('relationship') >>. In this case C<$row_object> is
passed to the coderef as C<< $args->{self_rowobj} >>, so a user can do the
use warnings;
use DBIx::Class::Carp;
-our %_pod_inherit_config =
+our %_pod_inherit_config =
(
class_map => { 'DBIx::Class::Relationship::CascadeActions' => 'DBIx::Class::Relationship' }
);
use Sub::Name ();
use base qw/DBIx::Class/;
-our %_pod_inherit_config =
+our %_pod_inherit_config =
(
class_map => { 'DBIx::Class::Relationship::ProxyMethods' => 'DBIx::Class::Relationship' }
);
=head1 DESCRIPTION
-DBIx::Class is faster than older ORMs like Class::DBI but it still isn't
+DBIx::Class is faster than older ORMs like Class::DBI but it still isn't
designed primarily for speed. Sometimes you need to quickly retrieve the data
from a massive resultset, while skipping the creation of fancy row objects.
Specifying this class as a C<result_class> for a resultset will change C<< $rs->next >>
my $cds = $artist->cds;
$cds->result_class('DBIx::Class::ResultClass::HashRefInflator');
- my $first = $cds->first;
+ my $first = $cds->first;
-C<$first> will B<not> be a hashref, it will be a normal CD row since
+C<$first> will B<not> be a hashref, it will be a normal CD row since
HashRefInflator only affects resultsets at inflation time, and prefetch causes
relations to be inflated when the master C<$artist> row is inflated.
$attrs->{'+columns'} = $self->_merge_attr($attrs->{'+columns'}, delete $attrs->{include_columns})
if exists $attrs->{include_columns};
- # columns are always placed first, however
+ # columns are always placed first, however
# Keep the X vs +X separation until _resolved_attrs time - this allows to
# delay the decision on whether to use a default select list ($rsrc->columns)
push(@created, $self->create($item));
}
return wantarray ? @created : \@created;
- }
+ }
else {
my $first = $data->[0];
In normal usage, the value of such columns should NOT be included at
all in the call to C<update_or_new>, even when set to C<undef>.
-See also L</find>, L</find_or_create> and L</find_or_new>.
+See also L</find>, L</find_or_create> and L</find_or_new>.
=cut
# analyze the order_by, and see if it is done over a function/nonexistentcolumn
# if this is the case we will need to wrap a subquery since the result of RSC
# *must* be a single column select
- my %collist = map
+ my %collist = map
{ $_ => 1, ($_ =~ /\./) ? () : ( "$alias.$_" => 1 ) }
($rs->result_source->columns, $column)
;
if (
scalar grep
{ ! $collist{$_->[0]} }
- ( $rs->result_source->schema->storage->_extract_order_criteria ($orig_attrs->{order_by} ) )
+ ( $rs->result_source->schema->storage->_extract_order_criteria ($orig_attrs->{order_by} ) )
) {
# nuke the prefetch before collapsing to sql
my $subq_rs = $rs->search;
Returns the next value of the column in the resultset (or C<undef> if
there is none).
-Much like L<DBIx::Class::ResultSet/next> but just returning the
+Much like L<DBIx::Class::ResultSet/next> but just returning the
one value.
=cut
See L<DBIx::Class::Schema/throw_exception> for details.
-=cut
+=cut
sub throw_exception {
my $self=shift;
$schema->resultset('Year2000CDs')->all();
- SELECT cdid, artist, title FROM
+ SELECT cdid, artist, title FROM
(SELECT cdid, artist, title FROM cd WHERE year ='2000') me
=back
An SQL query for your view. Will not be translated across database
syntaxes.
-=head2 deploy_depends_on
+=head2 deploy_depends_on
__PACKAGE__->result_source_instance->deploy_depends_on(
["MyApp::Schema::Result::Year","MyApp::Schema::Result::CD"]
=head2 STORABLE_thaw
Thaws frozen handle. Resets the internal schema reference to the package
-variable C<$thaw_schema>. The recommended way of setting this is to use
+variable C<$thaw_schema>. The recommended way of setting this is to use
C<< $schema->thaw($ice) >> which handles this for you.
=cut
#
# Returns mangled proto-sql, inner/outer strings of SQL QUOTED selectors
# with aliases (to be used in whatever select statement), and an alias
-# index hashref of QUOTED SEL => QUOTED ALIAS pairs (to maybe be used
+# index hashref of QUOTED SEL => QUOTED ALIAS pairs (to maybe be used
# for string-subst higher up).
# If an order_by is supplied, the inner select needs to bring out columns
# used in implicit (non-selected) orders, and the order condition itself
# as a new txn is started immediately on commit
$self->transaction_depth(1) if (
!$self->transaction_depth
- and
+ and
defined $self->_dbh_autocommit
and
! $self->_dbh_autocommit
# as a new txn is started immediately on commit
$self->transaction_depth(1) if (
!$self->transaction_depth
- and
+ and
defined $self->_dbh_autocommit
and
! $self->_dbh_autocommit
if ($data_type =~ /^(?:
l? (?:var)? char(?:acter)? (?:\s*varying)?
|
- (?:var)? binary (?:\s*varying)?
+ (?:var)? binary (?:\s*varying)?
|
raw
)\b/x
use base 'DBIx::Class::Storage::DBI';
use mro 'c3';
-=head1 NAME
+=head1 NAME
DBIx::Class::Storage::DBI::MultiColumnIn - Storage component for RDBMS supporting multicolumn in clauses
my @pcols = $rsrc->_pri_cols;
my $attrs = $rs->_resolved_attrs;
- # naive check - this is an internal method after all, we should know what we are doing
+ # naive check - this is an internal method after all, we should know what we are doing
$self->throw_exception ('Number of columns selected by supplied resultset does not match number of primary keys')
if ( ref $attrs->{select} ne 'ARRAY' or @{$attrs->{select}} != @pcols );
=head2 uniqueidentifierstr data type
If you use the C<uniqueidentifierstr> type with this driver, your queries may
-fail with:
+fail with:
Data truncated (SQL-01004)
# person me
# CONNECT BY
# parentid = prior persionid
-
+
connect_by_nocycle => { parentid => 'prior personid' }
=head1 NAME
-DBIx::Class::Storage::DBI::Replicated::Balancer - A Software Load Balancer
+DBIx::Class::Storage::DBI::Replicated::Balancer - A Software Load Balancer
=head1 SYNOPSIS
Replicant storages (slaves) handle all read only traffic. The assumption is
that your database will become readbound well before it becomes write bound
-and that being able to spread your read only traffic around to multiple
+and that being able to spread your read only traffic around to multiple
databases is going to help you to scale traffic.
This attribute returns the next slave to handle a read request. Your L</pool>
This method should be defined in the class which consumes this role.
Given a pool object, return the next replicant that will serve queries. The
-default behavior is to grab the first replicant it finds but you can write
-your own subclasses of L<DBIx::Class::Storage::DBI::Replicated::Balancer> to
+default behavior is to grab the first replicant it finds but you can write
+your own subclasses of L<DBIx::Class::Storage::DBI::Replicated::Balancer> to
support other balance systems.
This returns from the pool of active replicants. If there are no active
## Do we need to validate the replicants?
if(
- $self->has_auto_validate_every &&
+ $self->has_auto_validate_every &&
($self->auto_validate_every + $self->pool->last_validated) <= $now
- ) {
+ ) {
$self->pool->validate_replicants;
}
if (my $forced_pool = $args[-1]->{force_pool}) {
delete $args[-1]->{force_pool};
- return $self->_get_forced_pool($forced_pool)->select(@args);
+ return $self->_get_forced_pool($forced_pool)->select(@args);
} elsif($self->master->{transaction_depth}) {
return $self->master->select(@args);
} else {
if (my $forced_pool = $args[-1]->{force_pool}) {
delete $args[-1]->{force_pool};
- return $self->_get_forced_pool($forced_pool)->select_single(@args);
+ return $self->_get_forced_pool($forced_pool)->select_single(@args);
} elsif($self->master->{transaction_depth}) {
return $self->master->select_single(@args);
} else {
return $replicant;
} else {
$self->master->throw_exception("$forced_pool is not a named replicant.");
- }
+ }
}
=head1 AUTHOR
using it. It is not a document explaining how to setup MySQL native replication
either. Copious external resources are available for both. This document
presumes you have the basics down.
-
+
=head1 DESCRIPTION
L<DBIx::Class> supports a framework for using database replication. This system
-is integrated completely, which means once it's setup you should be able to
+is integrated completely, which means once it's setup you should be able to
automatically just start using a replication cluster without additional work or
changes to your code. Some caveats apply, primarily related to the proper use
of transactions (you are wrapping all your database modifying statements inside
L<MySQL::Sandbox>.
If you are using this with a L<Catalyst> based application, you may also want
-to see more recent updates to L<Catalyst::Model::DBIC::Schema>, which has
+to see more recent updates to L<Catalyst::Model::DBIC::Schema>, which has
support for replication configuration options as well.
=head1 REPLICATED STORAGE
is assigned a storage_type, which when fully connected will reflect your
underlying storage engine as defined by your chosen database driver. For
example, if you connect to a MySQL database, your storage_type will be
-L<DBIx::Class::Storage::DBI::mysql> Your storage type class will contain
+L<DBIx::Class::Storage::DBI::mysql> Your storage type class will contain
database specific code to help smooth over the differences between databases
and let L<DBIx::Class> do its thing.
If you want to use replication, you will override this setting so that the
-replicated storage engine will 'wrap' your underlying storages and present
+replicated storage engine will 'wrap' your underlying storages and present
a unified interface to the end programmer. This wrapper storage class will
delegate method calls to either a master database or one or more replicated
databases based on if they are read only (by default sent to the replicants)
-or write (reserved for the master). Additionally, the Replicated storage
+or write (reserved for the master). Additionally, the Replicated storage
will monitor the health of your replicants and automatically drop them should
one exceed configurable parameters. Later, it can automatically restore a
replicant when its health is restored.
a transaction, replicated storage will automatically delegate all database
traffic to the master storage. There are several ways to enable this high
integrity mode, but wrapping your statements inside a transaction is the easy
-and canonical option.
+and canonical option.
=head1 PARTS OF REPLICATED STORAGE
'balancer_args' get passed to the balancer when it's instantiated. All
balancers have the 'auto_validate_every' option. This is the number of seconds
we allow to pass between validation checks on a load balanced replicant. So
-the higher the number, the more possibility that your reads to the replicant
+the higher the number, the more possibility that your reads to the replicant
may be inconsistent with what's on the master. Setting this number too low
will result in increased database loads, so choose a number with care. Our
experience is that setting the number around 5 seconds results in a good
=head1 DESCRIPTION
In a replicated storage type, there is at least one replicant to handle the
-read-only traffic. The Pool class manages this replicant, or list of
+read-only traffic. The Pool class manages this replicant, or list of
replicants, and gives some methods for querying information about their status.
=head1 ATTRIBUTES
default=>'DBIx::Class::Storage::DBI',
handles=>{
'create_replicant' => 'new',
- },
+ },
);
=head2 replicants
}
$replicant->id($key);
- $self->set_replicant($key => $replicant);
+ $self->set_replicant($key => $replicant);
push @newly_created, $replicant;
}
if($lag_behind_master <= $self->maximum_lag) {
$replicant->active(1);
} else {
- $replicant->active(0);
+ $replicant->active(0);
}
- }
+ }
} else {
$replicant->active(0);
}
$replicant->active(0);
}
}
- ## Mark that we completed this validation.
- $self->_last_validated(time);
+ ## Mark that we completed this validation.
+ $self->_last_validated(time);
}
=head1 AUTHOR
Executes:
- PRAGMA foreign_keys = ON
+ PRAGMA foreign_keys = ON
See L<http://www.sqlite.org/foreignkeys.html> for more information.
DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
-my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
+my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
my ($datetime_parser, $datetime_formatter);
if (
! exists $sqltargs->{producer_args}{mysql_version}
- and
+ and
my $dver = $self->_server_info->{normalized_dbms_version}
) {
$sqltargs->{producer_args}{mysql_version} = $dver;
#
# This is the code producing joined subqueries like:
-# SELECT me.*, other.* FROM ( SELECT me.* FROM ... ) JOIN other ON ...
+# SELECT me.*, other.* FROM ( SELECT me.* FROM ... ) JOIN other ON ...
#
sub _adjust_select_args_for_complex_prefetch {
my ($self, $from, $select, $where, $attrs) = @_;
# So it looks like we will have to switch some stuff around.
# local() is useless here as we will be leaving the scope
# anyway, and deep cloning is just too fucking expensive
- # So replace the first hashref in the node arrayref manually
+ # So replace the first hashref in the node arrayref manually
my @new_from = ($from->[0]);
my $sw_idx = { map { (values %$_), 1 } @$switch_branch }; #there's one k/v per join-path
database engines, as explained below.
If you have specific questions about the integrity of your data in light
-of this development - please
+of this development - please
L<join us on IRC or the mailing list|DBIx::Class/GETTING HELP/SUPPORT>
to further discuss your concerns with the team.
isa_ok $artist1, 'DBICTest::Artist';
isa_ok $artist2, 'DBICTest::Artist';
isa_ok $artist3, 'DBICTest::Artist';
- isa_ok $undef, 'DBICTest::Artist';
+ isa_ok $undef, 'DBICTest::Artist';
ok $artist1->name eq '001First Artist', "Got Expected Artist Name for Artist001";
ok $artist2->name eq '002Second Artist', "Got Expected Artist Name for Artist002";
ok $artist3->name eq '003Third Artist', "Got Expected Artist Name for Artist003";
- ok !defined $undef->name, "Got Expected Artist Name for Artist004";
+ ok !defined $undef->name, "Got Expected Artist Name for Artist004";
ok $artist1->cds->count eq 3, "Got Right number of CDs for Artist1";
ok $artist2->cds->count eq 0, "Got Right number of CDs for Artist2";
ok $artist3->cds->count eq 1, "Got Right number of CDs for Artist3";
- ok $undef->cds->count eq 1, "Got Right number of CDs for Artist4";
+ ok $undef->cds->count eq 1, "Got Right number of CDs for Artist4";
ARTIST1CDS: {
isa_ok( $crap, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $girl, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
## Find the expected information?
isa_ok( $crap, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $girl, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
## Find the expected information?
## Create the expected children sub objects?
ok( $crap->cds->count == 0, "got Expected Number of Cds");
- ok( $girl->cds->count == 2, "got Expected Number of Cds");
+ ok( $girl->cds->count == 2, "got Expected Number of Cds");
ok( $damn->cds->count == 3, "got Expected Number of Cds");
ok( $formerly->cds->count == 1, "got Expected Number of Cds");
BELONGS_TO_NO_PKs: {
- ## Test from a belongs_to perspective, should create artist first,
+ ## Test from a belongs_to perspective, should create artist first,
## then CD with artistid. This test we let the system automatically
## create the PK's. Chances are good you'll use it this way mostly.
title => 'Some CD4',
year => '1997',
artist => { name => 'Fred BloggsD'},
- },
+ },
];
my ($cdA, $cdB) = $cd_rs->populate($cds);
BELONGS_TO_WITH_PKs: {
- ## Test from a belongs_to perspective, should create artist first,
+ ## Test from a belongs_to perspective, should create artist first,
## then CD with artistid. This time we try setting the PK's
my $aid = $art_rs->get_column('artistid')->max || 0;
title => 'Some CD4',
year => '1997',
artist => { artistid=> ++$aid, name => 'Fred BloggsF'},
- },
+ },
];
my ($cdA, $cdB) = $cd_rs->populate($cds);
## Did it use the condition in the resultset?
cmp_ok( $more_crap->rank, '==', 42, "Got Correct rank for result object");
- }
+ }
}
VOID_CONTEXT: {
- ## All these tests check the ability to use populate without asking for
+ ## All these tests check the ability to use populate without asking for
## any returned resultsets. This uses bulk_insert as much as possible
## in order to increase speed.
cds => [
{ title => 'VOID_PK_My parents sold me to a record company' ,year => 2005 },
{ title => 'VOID_PK_Why Am I So Ugly?', year => 2006 },
- { title => 'VOID_PK_I Got Surgery and am now Popular', year => 2007 }
+ { title => 'VOID_PK_I Got Surgery and am now Popular', year => 2007 }
],
},
{
isa_ok( $crap, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $girl, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $undef, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $undef, 'DBICTest::Artist', "Got 'Artist'");
## Find the expected information?
ok( $crap->name eq 'VOID_PK_Manufactured Crap', "Got Correct name 'VOID_PK_Manufactured Crap' for result object");
ok( $girl->name eq 'VOID_PK_Angsty-Whiny Girl', "Got Correct name for result object");
- ok( $damn->name eq 'VOID_PK_Like I Give a Damn', "Got Correct name for result object");
+ ok( $damn->name eq 'VOID_PK_Like I Give a Damn', "Got Correct name for result object");
ok( $formerly->name eq 'VOID_PK_Formerly Named', "Got Correct name for result object");
- ok( !defined $undef->name, "Got Correct name 'is undef' for result object");
+ ok( !defined $undef->name, "Got Correct name 'is undef' for result object");
## Create the expected children sub objects?
ok( $crap->can('cds'), "Has cds relationship");
ok( $girl->can('cds'), "Has cds relationship");
ok( $damn->can('cds'), "Has cds relationship");
ok( $formerly->can('cds'), "Has cds relationship");
- ok( $undef->can('cds'), "Has cds relationship");
+ ok( $undef->can('cds'), "Has cds relationship");
ok( $crap->cds->count == 0, "got Expected Number of Cds");
- ok( $girl->cds->count == 2, "got Expected Number of Cds");
+ ok( $girl->cds->count == 2, "got Expected Number of Cds");
ok( $damn->cds->count == 3, "got Expected Number of Cds");
ok( $formerly->cds->count == 1, "got Expected Number of Cds");
ok( $undef->cds->count == 1, "got Expected Number of Cds");
BELONGS_TO_WITH_PKs: {
- ## Test from a belongs_to perspective, should create artist first,
+ ## Test from a belongs_to perspective, should create artist first,
## then CD with artistid. This time we try setting the PK's
my $aid = $art_rs->get_column('artistid')->max || 0;
BELONGS_TO_NO_PKs: {
- ## Test from a belongs_to perspective, should create artist first,
+ ## Test from a belongs_to perspective, should create artist first,
## then CD with artistid.
my $cds = [
title => 'Some CD5BB',
year => '1997',
artist => { name => undef},
- },
+ },
];
$cd_rs->populate($cds);
## with the parent having many children and let the keys be automatic
my $artists = [
- {
+ {
name => 'VOID_Angsty-Whiny Girl',
cds => [
{ title => 'VOID_My First CD', year => 2006 },
{ title => 'VOID_Yet More Tweeny-Pop crap', year => 2007 },
- ],
- },
+ ],
+ },
{
name => 'VOID_Manufactured Crap',
},
cds => [
{ title => 'VOID_My parents sold me to a record company' ,year => 2005 },
{ title => 'VOID_Why Am I So Ugly?', year => 2006 },
- { title => 'VOID_I Got Surgery and am now Popular', year => 2007 }
+ { title => 'VOID_I Got Surgery and am now Popular', year => 2007 }
],
},
- {
+ {
name => 'VOID_Formerly Named',
cds => [
{ title => 'VOID_One Hit Wonder', year => 2006 },
- ],
- },
+ ],
+ },
];
## Get the result row objects.
isa_ok( $crap, 'DBICTest::Artist', "Got 'Artist'");
isa_ok( $girl, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
- isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $damn, 'DBICTest::Artist', "Got 'Artist'");
+ isa_ok( $formerly, 'DBICTest::Artist', "Got 'Artist'");
## Find the expected information?
ok( $crap->name eq 'VOID_Manufactured Crap', "Got Correct name for result object");
ok( $girl->name eq 'VOID_Angsty-Whiny Girl', "Got Correct name for result object");
- ok( $damn->name eq 'VOID_Like I Give a Damn', "Got Correct name for result object");
+ ok( $damn->name eq 'VOID_Like I Give a Damn', "Got Correct name for result object");
ok( $formerly->name eq 'VOID_Formerly Named', "Got Correct name for result object");
## Create the expected children sub objects?
ok( $formerly->can('cds'), "Has cds relationship");
ok( $crap->cds->count == 0, "got Expected Number of Cds");
- ok( $girl->cds->count == 2, "got Expected Number of Cds");
+ ok( $girl->cds->count == 2, "got Expected Number of Cds");
ok( $damn->cds->count == 3, "got Expected Number of Cds");
ok( $formerly->cds->count == 1, "got Expected Number of Cds");
## Did it use the condition in the resultset?
cmp_ok( $more_crap->rank, '==', 42, "Got Correct rank for result object");
- }
+ }
}
ARRAYREF_OF_ARRAYREF_STYLE: {
my ($cooler, $lamer) = $restricted_art_rs->populate([
[qw/artistid name/],
[1003, 'Cooler'],
- [1004, 'Lamer'],
+ [1004, 'Lamer'],
]);
is $cooler->name, 'Cooler', 'Correct Name';
- is $lamer->name, 'Lamer', 'Correct Name';
+ is $lamer->name, 'Lamer', 'Correct Name';
cmp_ok $cooler->rank, '==', 42, 'Correct Rank';
## Did it use the condition in the resultset?
cmp_ok( $mega_lamer->rank, '==', 42, "Got Correct rank for result object");
- }
+ }
VOID_CONTEXT_WITH_COND_FROM_RS: {
my $exp_warn = qr/The many-to-many relationship 'bars' is trying to create/;
{
- my @w;
+ my @w;
local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
my $code = gen_code ( suffix => 1 );
eval "$code";
}
{
- my @w;
+ my @w;
local $SIG{__WARN__} = sub { $_[0] =~ $exp_warn ? push @w, $_[0] : warn $_[0] };
my $code = gen_code ( suffix => 2 );
aba_name_artists
aba_name_artists_and_2010_cds_with_many_tracks
/],
- "SQLT view order triumphantly matches our order."
+ "SQLT view order triumphantly matches our order."
);
#################### AND WHAT ABOUT USING THE SCHEMA?
aba_name_artists_and_2010_cds_with_many_tracks
aba_name_artists
/],
- "SQLT view order triumphantly matches our order."
+ "SQLT view order triumphantly matches our order."
);
#################### AND WHAT ABOUT USING THE SCHEMA2?
use warnings;
use lib 't/lib';
-use DBICTest; # do not remove even though it is not used
+use DBICTest; # do not remove even though it is not used
use Test::More tests => 8;
sub _chk_warning {
) {
fail ("Unexpected require of '$req' by $caller[0] ($caller[1] line $caller[2])");
- if ($ENV{TEST_VERBOSE}) {
+ if ($ENV{TEST_VERBOSE}) {
my ($i, @stack) = 1;
while (my @f = caller($i++) ) {
push @stack, \@f;
is($new_again->ID, 'DBICTest::Artist|artist|artistid=4', 'unique object id generated correctly');
-# test that store_column is called once for create() for non sequence columns
+# test that store_column is called once for create() for non sequence columns
{
ok(my $artist = $schema->resultset('Artist')->create({name => 'store_column test'}));
is($artist->name, 'X store_column test'); # used to be 'X X store...'
group_by => [ qw/position title/ ]
}
);
- is($tcount->count, 13, 'multiple column COUNT DISTINCT using column syntax ok');
+ is($tcount->count, 13, 'multiple column COUNT DISTINCT using column syntax ok');
}
my $tag_rs = $schema->resultset('Tag')->search(
my @artsn = $schema->resultset('SourceNameArtists')->search({}, { order_by => 'name DESC' });
is(@artsn, 4, "Four artists returned");
-
+
# make sure subclasses that don't set source_name are ok
ok($schema->source('ArtistSubclass'), 'ArtistSubclass exists');
}
use strict;
-use warnings;
+use warnings;
use Test::More tests => 2;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
# XXX: Is storage->dbh the only way to get a dbh?
$schema->storage->txn_begin;
for (10..15) {
- $schema->resultset("Artist")->create( {
+ $schema->resultset("Artist")->create( {
artistid => $_,
name => "artist number $_",
} );
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
});
my $row = $rs->search({}, {
- order_by => 'cdid',
+ order_by => 'cdid',
offset => 3,
rows => 1
})->single;
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
#'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
-# make sure sqlt_type overrides work (::Storage::DBI::mysql does this)
+# make sure sqlt_type overrides work (::Storage::DBI::mysql does this)
{
my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
]);
#
-# try a distinct + prefetch on tables with identically named columns
+# try a distinct + prefetch on tables with identically named columns
# (mysql doesn't seem to like subqueries with equally named columns)
#
'Zero-year groups successfully',
);
- # convoluted search taken verbatim from list
+ # convoluted search taken verbatim from list
my $restrict_rs = $rs->search({ -and => [
year => { '!=', 0 },
year => { '!=', undef }
} 'with_deferred_fk_checks code survived';
is eval { $schema->resultset('Track')->find(999)->title }, 'deferred FK track',
- 'code in with_deferred_fk_checks worked';
+ 'code in with_deferred_fk_checks worked';
throws_ok {
$schema->resultset('Track')->create({
'charfield' => {
'data_type' => 'CHAR',
'is_nullable' => 1,
- 'size' => 10
+ 'size' => 10
},
};
if $opts_name eq 'use_dynamic_cursors' &&
$schema->storage->using_freetds;
- local $TODO =
+ local $TODO =
'these tests fail on freetds with dynamic cursors for some reason'
if $freetds_and_dynamic_cursors;
local $ENV{DBIC_NULLABLE_KEY_NOWARN} = 1
eval { $dbh->do('DROP TABLE bindtype_test') };
$dbh->do(qq[
- CREATE TABLE bindtype_test
+ CREATE TABLE bindtype_test
(
id INT IDENTITY PRIMARY KEY,
bytea IMAGE NULL,
$binstr{'large'} = $binstr{'small'} x 1024;
my $maxloblen = length $binstr{'large'};
-
+
if (not $schema->storage->using_freetds) {
$dbh->{'LongReadLen'} = $maxloblen * 2;
} else {
id INT IDENTITY PRIMARY KEY,
a_computed_column AS getdate(),
a_timestamp timestamp,
- charfield VARCHAR(20) DEFAULT 'foo'
+ charfield VARCHAR(20) DEFAULT 'foo'
)
SQL
});
} 'with_deferred_fk_checks code survived';
is eval { $schema->resultset('Track')->find(999)->title }, 'deferred FK track',
- 'code in with_deferred_fk_checks worked';
+ 'code in with_deferred_fk_checks worked';
throws_ok {
$schema->resultset('Track')->create({
ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
}
}
-
+
my @uuid_types = qw/uniqueidentifier uniqueidentifierstr/;
# test uniqueidentifiers (and the cursor_class).
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
# requires SQL::Abstract >= 1.20
$it = $schema->resultset("CD")->search(
{ title => [
- -and =>
+ -and =>
{
-like => '%bees'
},
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
[ 4, 7 ],
[ 4, 8 ],
]);
-
+
sub cd_count {
return $schema->resultset("CD")->count;
}
is(cd_count(), 8, '8 rows in table cd');
is(tk_count(), 7, '7 rows in table twokeys');
-
+
sub artist1 {
return $schema->resultset("CD")->search(
{ 'artist.name' => 'Caterwauler McCrae' },
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Warn;
$cd->update;
-is($queries, 1, 'liner_notes (might_have) not prefetched - do not load
+is($queries, 1, 'liner_notes (might_have) not prefetched - do not load
liner_notes on update');
$schema->storage->debug($sdebug);
$cd2->update;
-is($queries, 1, 'liner_notes (might_have) prefetched - do not load
+is($queries, 1, 'liner_notes (might_have) prefetched - do not load
liner_notes on update');
warning_like {
{
local $ENV{DBIC_DONT_VALIDATE_RELS} = 1;
- warning_is {
+ warning_is {
DBICTest::Schema::Bookmark->might_have(
slinky => 'DBICTest::Schema::Link',
{ "foreign.id" => "self.link" },
}
-my $translator = SQL::Translator->new(
+my $translator = SQL::Translator->new(
parser_args => {
'DBIx::Schema' => $schema,
},
{
'display' => 'twokeys->cd',
'name' => 'twokeys_fk_cd', 'index_name' => 'twokeys_idx_cd',
- 'selftable' => 'twokeys', 'foreigntable' => 'cd',
- 'selfcols' => ['cd'], 'foreigncols' => ['cdid'],
+ 'selftable' => 'twokeys', 'foreigntable' => 'cd',
+ 'selfcols' => ['cd'], 'foreigncols' => ['cdid'],
'noindex' => 1,
on_delete => '', on_update => '', deferrable => 0,
},
{
'display' => 'twokeys->artist',
'name' => 'twokeys_fk_artist', 'index_name' => 'twokeys_idx_artist',
- 'selftable' => 'twokeys', 'foreigntable' => 'artist',
+ 'selftable' => 'twokeys', 'foreigntable' => 'artist',
'selfcols' => ['artist'], 'foreigncols' => ['artistid'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'fourkeys_to_twokeys->twokeys',
'name' => 'fourkeys_to_twokeys_fk_t_artist_t_cd', 'index_name' => 'fourkeys_to_twokeys_idx_t_artist_t_cd',
- 'selftable' => 'fourkeys_to_twokeys', 'foreigntable' => 'twokeys',
- 'selfcols' => ['t_artist', 't_cd'], 'foreigncols' => ['artist', 'cd'],
+ 'selftable' => 'fourkeys_to_twokeys', 'foreigntable' => 'twokeys',
+ 'selfcols' => ['t_artist', 't_cd'], 'foreigncols' => ['artist', 'cd'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'fourkeys_to_twokeys->fourkeys', 'index_name' => 'fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye',
'name' => 'fourkeys_to_twokeys_fk_f_foo_f_bar_f_hello_f_goodbye',
- 'selftable' => 'fourkeys_to_twokeys', 'foreigntable' => 'fourkeys',
+ 'selftable' => 'fourkeys_to_twokeys', 'foreigntable' => 'fourkeys',
'selfcols' => [qw(f_foo f_bar f_hello f_goodbye)],
- 'foreigncols' => [qw(foo bar hello goodbye)],
+ 'foreigncols' => [qw(foo bar hello goodbye)],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
],
{
'display' => 'cd_to_producer->cd',
'name' => 'cd_to_producer_fk_cd', 'index_name' => 'cd_to_producer_idx_cd',
- 'selftable' => 'cd_to_producer', 'foreigntable' => 'cd',
+ 'selftable' => 'cd_to_producer', 'foreigntable' => 'cd',
'selfcols' => ['cd'], 'foreigncols' => ['cdid'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'cd_to_producer->producer',
'name' => 'cd_to_producer_fk_producer', 'index_name' => 'cd_to_producer_idx_producer',
- 'selftable' => 'cd_to_producer', 'foreigntable' => 'producer',
+ 'selftable' => 'cd_to_producer', 'foreigntable' => 'producer',
'selfcols' => ['producer'], 'foreigncols' => ['producerid'],
on_delete => '', on_update => '', deferrable => 1,
},
{
'display' => 'self_ref_alias->self_ref for self_ref',
'name' => 'self_ref_alias_fk_self_ref', 'index_name' => 'self_ref_alias_idx_self_ref',
- 'selftable' => 'self_ref_alias', 'foreigntable' => 'self_ref',
+ 'selftable' => 'self_ref_alias', 'foreigntable' => 'self_ref',
'selfcols' => ['self_ref'], 'foreigncols' => ['id'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'self_ref_alias->self_ref for alias',
'name' => 'self_ref_alias_fk_alias', 'index_name' => 'self_ref_alias_idx_alias',
- 'selftable' => 'self_ref_alias', 'foreigntable' => 'self_ref',
+ 'selftable' => 'self_ref_alias', 'foreigntable' => 'self_ref',
'selfcols' => ['alias'], 'foreigncols' => ['id'],
on_delete => '', on_update => '', deferrable => 1,
},
{
'display' => 'cd->artist',
'name' => 'cd_fk_artist', 'index_name' => 'cd_idx_artist',
- 'selftable' => 'cd', 'foreigntable' => 'artist',
+ 'selftable' => 'cd', 'foreigntable' => 'artist',
'selfcols' => ['artist'], 'foreigncols' => ['artistid'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'artist_undirected_map->artist for id1',
'name' => 'artist_undirected_map_fk_id1', 'index_name' => 'artist_undirected_map_idx_id1',
- 'selftable' => 'artist_undirected_map', 'foreigntable' => 'artist',
+ 'selftable' => 'artist_undirected_map', 'foreigntable' => 'artist',
'selfcols' => ['id1'], 'foreigncols' => ['artistid'],
on_delete => 'RESTRICT', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'artist_undirected_map->artist for id2',
'name' => 'artist_undirected_map_fk_id2', 'index_name' => 'artist_undirected_map_idx_id2',
- 'selftable' => 'artist_undirected_map', 'foreigntable' => 'artist',
+ 'selftable' => 'artist_undirected_map', 'foreigntable' => 'artist',
'selfcols' => ['id2'], 'foreigncols' => ['artistid'],
on_delete => '', on_update => '', deferrable => 1,
},
{
'display' => 'track->cd',
'name' => 'track_fk_cd', 'index_name' => 'track_idx_cd',
- 'selftable' => 'track', 'foreigntable' => 'cd',
+ 'selftable' => 'track', 'foreigntable' => 'cd',
'selfcols' => ['cd'], 'foreigncols' => ['cdid'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'treelike->treelike for parent',
'name' => 'treelike_fk_parent', 'index_name' => 'treelike_idx_parent',
- 'selftable' => 'treelike', 'foreigntable' => 'treelike',
+ 'selftable' => 'treelike', 'foreigntable' => 'treelike',
'selfcols' => ['parent'], 'foreigncols' => ['id'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'twokeytreelike->twokeytreelike for parent1,parent2',
'name' => 'twokeytreelike_fk_parent1_parent2', 'index_name' => 'twokeytreelike_idx_parent1_parent2',
- 'selftable' => 'twokeytreelike', 'foreigntable' => 'twokeytreelike',
+ 'selftable' => 'twokeytreelike', 'foreigntable' => 'twokeytreelike',
'selfcols' => ['parent1', 'parent2'], 'foreigncols' => ['id1','id2'],
on_delete => '', on_update => '', deferrable => 1,
},
{
'display' => 'tags->cd',
'name' => 'tags_fk_cd', 'index_name' => 'tags_idx_cd',
- 'selftable' => 'tags', 'foreigntable' => 'cd',
+ 'selftable' => 'tags', 'foreigntable' => 'cd',
'selfcols' => ['cd'], 'foreigncols' => ['cdid'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'bookmark->link',
'name' => 'bookmark_fk_link', 'index_name' => 'bookmark_idx_link',
- 'selftable' => 'bookmark', 'foreigntable' => 'link',
+ 'selftable' => 'bookmark', 'foreigntable' => 'link',
'selfcols' => ['link'], 'foreigncols' => ['id'],
on_delete => 'SET NULL', on_update => 'CASCADE', deferrable => 1,
},
{
'display' => 'forceforeign->artist',
'name' => 'forceforeign_fk_artist', 'index_name' => 'forceforeign_idx_artist',
- 'selftable' => 'forceforeign', 'foreigntable' => 'artist',
- 'selfcols' => ['artist'], 'foreigncols' => ['artistid'],
+ 'selftable' => 'forceforeign', 'foreigntable' => 'artist',
+ 'selfcols' => ['artist'], 'foreigncols' => ['artistid'],
'noindex' => 1,
on_delete => '', on_update => '', deferrable => 1,
},
skip ('Artist sqlt_deploy_hook is only called with an SQLite backend', 1)
if $schema->storage->sqlt_type ne 'SQLite';
- ok( ( grep
+ ok( ( grep
{ $_->name eq 'artist_name_hookidx' }
$tschema->get_table('artist')->get_indices
), 'sqlt_deploy_hook fired within a resultsource');
CAND_INDEX:
for my $cand_index ( $table->get_indices ) {
-
+
next CAND_INDEX if $index->{name} && $cand_index->name ne $index->{name}
|| $index->{type} && $cand_index->type ne $index->{type};
# vim: filetype=perl
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
$employee->update;
ok(
check_rs($employees->search_rs({group_id_2=>4, group_id_3=>1}))
- && check_rs($employees->search_rs({group_id_2=>1, group_id_3=>1})),
- "overloaded multicol update 1"
+ && check_rs($employees->search_rs({group_id_2=>1, group_id_3=>1})),
+ "overloaded multicol update 1"
);
$employee = $employees->search({group_id_2=>4, group_id_3=>1})->first;
$employee->update({group_id_2=>2});
ok( check_rs($employees->search_rs({group_id_2=>4, group_id_3=>1}))
- && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>1})),
- "overloaded multicol update 2"
+ && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>1})),
+ "overloaded multicol update 2"
);
$employee = $employees->search({group_id_2=>3, group_id_3=>1})->first;
$employee->update();
ok( check_rs($employees->search_rs({group_id_2=>3, group_id_3=>1}))
&& check_rs($employees->search_rs({group_id_2=>1, group_id_3=>3})),
- "overloaded multicol update 3"
+ "overloaded multicol update 3"
);
$employee = $employees->search({group_id_2=>3, group_id_3=>1})->first;
$employee->update({group_id_2=>2, group_id_3=>3});
ok( check_rs($employees->search_rs({group_id_2=>3, group_id_3=>1}))
- && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>3})),
- "overloaded multicol update 4"
+ && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>3})),
+ "overloaded multicol update 4"
);
$employee = $employees->search({group_id_2=>3, group_id_3=>2})->first;
$employee->update({group_id_2=>2, group_id_3=>4, position=>2});
ok( check_rs($employees->search_rs({group_id_2=>3, group_id_3=>2}))
- && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>4})),
- "overloaded multicol update 5"
+ && check_rs($employees->search_rs({group_id_2=>2, group_id_3=>4})),
+ "overloaded multicol update 5"
);
sub hammer_rs {
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
DBICVersion::Schema->connect({
dsn => $dsn,
- user => $user,
+ user => $user,
pass => $pass,
ignore_version => 1
});
-
+
ok($get_db_version_run == 0, "attributes pulled from hashref connect_info");
$get_db_version_run = 0;
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
{
my $cd_rc = $schema->resultset("CD")->result_class;
-
+
throws_ok {
$schema->resultset("Artist")
->search_rs({}, {result_class => "IWillExplode"})
my $cd_rs3 = $schema->resultset("Artist")->search_rs({},{})->related_resultset('cds');
is($cd_rs->result_class, $cd_rc, 'Correct cd3 result_class');
-
+
isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class');
}
{
my $cd_rc = $schema->resultset("CD")->result_class;
-
+
my $artist_rs = $schema->resultset("Artist")
->search_rs({}, {result_class => "IWillExplode"})->search({artistid => 1});
is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class');
-
+
my $cd_rs = $artist_rs->related_resultset('cds');
is($cd_rs->result_class, $cd_rc, 'Correct cd result_class');
-
- isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class');
+
+ isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class');
isa_ok(eval{ $cd_rs->search({ cdid => 1 })->first }, $cd_rc, 'Inflated into correct cd result_class');
}
my $additional_sqltargs = $args->{args} || {};
my $sqltargs = {
- add_drop_table => 1,
+ add_drop_table => 1,
ignore_constraint_names => 1,
ignore_index_names => 1,
%{$additional_sqltargs}
$admin->insert('Employee', {name =>'Aran'});
- my $expected_data = [
+ my $expected_data = [
[$employee->result_source->columns() ],
[1,1,undef,undef,undef,'Trout',undef],
[2,2,undef,undef,undef,'Aran',undef]
eval { my $id = Film->title };
#like $@, qr/class method/, "Can't get title with no object";
ok $@, "Can't get title with no object";
-}
+}
eval { my $duh = Film->insert; };
like $@, qr/create needs a hashref/, "needs a hashref";
# Test that a disconnect doesnt harm anything.
{
- # SQLite is loud on disconnect/reconnect.
+ # SQLite is loud on disconnect/reconnect.
# This is solved in DBIC but not in ContextualFetch
local $SIG{__WARN__} = sub {
warn @_ unless $_[0] =~
my $btaste4 = Film->retrieve('Bad Taste');
isnt refaddr $btaste2, refaddr $btaste4,
"Clearing cache and retrieving again gives new object";
-
+
$btaste=Film->insert({
Title => 'Bad Taste 2',
Director => 'Peter Jackson',
$btaste2 = Film->retrieve('Bad Taste 2');
is refaddr $btaste, refaddr $btaste2,
"Creating and retrieving gives ref to same object";
-
+
}
BEGIN {
eval "use DBIx::Class::CDBICompat;";
- plan $@
+ plan $@
? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required')
: (tests => 36)
;
}, undef, 23, $l->this);
is $l->oop, 23;
-
+
$l->delete;
}
inflate => sub { Date::Simple->new($_[0] . '-01-01') },
deflate => 'format'
);
-
+
my $l = Lazy->create({
this => 89,
that => 2,
SET orp = ?
WHERE this = ?
}, undef, 1987, $l->this);
-
+
is $l->orp, '1987-01-01';
$l->orp(2007);
is $l->orp, '2007-01-01'; # make sure it's inflated
$l->update;
-
+
ok $l->db_Main->do(qq{
UPDATE @{[ $l->table ]}
SET orp = ?
}, undef, 1942, $l->this);
is $l->orp, '1942-01-01';
-
+
$l->delete;
}
oop => 3,
opop => 4,
});
-
+
# Delete the object without it knowing.
Lazy->db_Main->do(qq[
DELETE
FROM @{[ Lazy->table ]}
WHERE this = 99
]);
-
+
$l->eep;
-
+
# The problem was when an object had an inflated object
# loaded. _flesh() would set _column_data to undef and
# get_column() would think nothing was there.
isa_ok($bar->fav, "Foo");
isa_ok($foo->fav, "Film");
-{
+{
my $foo;
Foo->add_trigger(after_create => sub { $foo = shift->fav });
my $gwh = Foo->create({ id => 93, fav => 'Good Will Hunting' });
ok $ver->delete, "Delete";
{
- Film->add_trigger(before_create => sub {
+ Film->add_trigger(before_create => sub {
my $self = shift;
ok !$self->_attribute_exists('title'), "PK doesn't auto-vivify";
});
$blurb = Blurb->retrieve('Bad Taste');
is $blurb, undef, "Blurb has gone";
}
-
+
}
{
my @cols = Film->columns('Essential');
is_deeply \@cols, ['title'], "1 Column in essential";
is +Film->transform_sql('__ESSENTIAL__'), 'title', '__ESSENTIAL__ expansion';
-
+
# This provides a more interesting test
Film->columns(Essential => qw(title rating));
is +Film->transform_sql('__ESSENTIAL__'), 'title, rating',
SELECT __ESSENTIAL__
FROM __TABLE__
WHERE __TABLE__.rating = 'PG'
- ORDER BY title DESC
+ ORDER BY title DESC
}
);
SELECT __ESSENTIAL__
FROM __TABLE__
WHERE rating = ?
- ORDER BY title DESC
+ ORDER BY title DESC
}
);
WHERE __IDENTIFIER__
}
);
-
+
my $film = Film->retrieve_all->first;
my @found = Film->search_by_id($film->id);
is @found, 1;
Film->set_sql(
namerate => qq{
SELECT __ESSENTIAL(f)__
- FROM __TABLE(=f)__, __TABLE(Actor=a)__
- WHERE __JOIN(a f)__
+ FROM __TABLE(=f)__, __TABLE(Actor=a)__
+ WHERE __JOIN(a f)__
AND a.name LIKE ?
AND f.rating = ?
- ORDER BY title
+ ORDER BY title
}
);
Film->set_sql(
ratename => qq{
SELECT __ESSENTIAL(f)__
- FROM __TABLE(=f)__, __TABLE(Actor=a)__
- WHERE __JOIN(f a)__
+ FROM __TABLE(=f)__, __TABLE(Actor=a)__
+ WHERE __JOIN(f a)__
AND f.rating = ?
AND a.name LIKE ?
- ORDER BY title
+ ORDER BY title
}
);
#{ # Fail on cascade
# local $TODO = 'cascade => "Fail" unimplemented';
-#
+#
# Director->has_many(nasties => Film => { cascade => 'Fail' });
#
# my $dir = Director->insert({ name => "Nasty Noddy" });
use base qw(DBIx::Class::CDBICompat);
Temp::DBI->columns(All => qw(id date));
-my $strptime_inflate = sub {
- Time::Piece->strptime(shift, "%Y-%m-%d")
+my $strptime_inflate = sub {
+ Time::Piece->strptime(shift, "%Y-%m-%d")
};
Temp::DBI->has_a(
date => 'Time::Piece',
eval {
my $data = $data;
$data->{sheep} = 1;
- ok $bt = Film->insert($data), "Modified accessor - with
+ ok $bt = Film->insert($data), "Modified accessor - with
accessor";
isa_ok $bt, "Film";
};
is( $it->next, undef, "next past end of page ok" );
# second page
-( $pager, $it ) = Film->page(
+( $pager, $it ) = Film->page(
{},
{ rows => 3,
page => 2 }
is_deeply [sort map $_->Title, @supers],
[sort ("Super Fuzz", "Superman")], 'like';
}
-
+
my @all = Film->search_where({}, { order_by => "Title ASC" });
is_deeply ["Batman", "Super Fuzz", "Superman"],
} '', 'DBIC_CDBICOMPAT_HASH_WARN controls warnings';
-{
+{
$waves->rating("R");
$waves->update;
-
+
no warnings 'redefine';
local *Film::rating = sub {
return "wibble";
};
-
+
is $waves->{rating}, "R";
}
return "movie" if lc $col eq "film";
return $col;
};
-
+
require Actor;
Actor->has_a( film => "Film" );
name => 'Emily Watson',
film => $waves,
});
-
+
ok !eval { $actor->film };
is $actor->{film}->id, $waves->id,
'hash access still works despite lack of accessor';
tdate => '1949-02-01',
});
isa_ok $foo, 'MyFoo';
-
+
isa_ok $foo->{tdate}, 'Date::Simple';
is $foo->{tdate}->year, 1949;
}
my $film = Foo->construct({
temp_thing => 23
});
-
+
::is $film->temp_thing, 23, "construct sets temp columns";
}
}
{
- package # hide from PAUSE
+ package # hide from PAUSE
MyFilm;
use base 'DBIC::Test::SQLite';
{
Film->nocache(1);
-
+
my $film1 = Film->retrieve( "This Is Spinal Tap" );
my $film2 = Film->retrieve( "This Is Spinal Tap" );
$film1->Director("Marty DiBergi");
is $film2->Director, "Rob Reiner",
'caching turned off';
-
+
$film1->discard_changes;
}
{ order_by => 'title',
rows => 3,
page => 1 } );
-
+
cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" );
cmp_ok( $pager->next_page, '==', 2, "next_page ok" );
# based on a failing criteria submitted by waswas
( $pager, $it ) = DBICTest::CD->page(
{ title => [
- -and =>
+ -and =>
{
-like => '%bees'
},
-package # hide from PAUSE
+package # hide from PAUSE
Actor;
use strict;
return qq{
id INTEGER PRIMARY KEY,
name CHAR(40),
- film VARCHAR(255),
+ film VARCHAR(255),
salary INT
}
}
-package # hide from PAUSE
+package # hide from PAUSE
ActorAlias;
use strict;
-package # hide from PAUSE
+package # hide from PAUSE
CDBase;
use strict;
salary INT
}
}
-
+
=head1 DESCRIPTION
This provides a simple base class for DBIx::Class::CDBICompat tests using
-package # hide from PAUSE
+package # hide from PAUSE
Director;
use strict;
-package # hide from PAUSE
+package # hide from PAUSE
Film;
use base 'DBIC::Test::SQLite';
}
}
-sub create_test_film {
+sub create_test_film {
return shift->create({
Title => 'Bad Taste',
Director => 'Peter Jackson',
-package # hide from PAUSE
+package # hide from PAUSE
Lazy;
use base 'DBIC::Test::SQLite';
-package # hide from PAUSE
+package # hide from PAUSE
Log;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
MyFilm;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
MyFoo;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
MyStar;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
MyStarLink;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
MyStarLinkMCPK;
use base 'MyBase';
-package # hide from PAUSE
+package # hide from PAUSE
Order;
use strict;
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
$rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1 });
is($get_count->($rs), 7, 'Count with IN subquery with outside distinct');
- $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1, select => 'tag' }),
+ $rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->get_column('tag')->as_query } }, { distinct => 1, select => 'tag' }),
is($get_count->($rs), 2, 'Count with IN subquery with outside distinct on a single column');
$rs = $schema->resultset('Tag')->search({ tag => { -in => $in_rs->search({}, { group_by => 'tag' })->get_column('tag')->as_query } });
local *DBICTest::Artist::DESTROY;
local *DBICTest::Artist::DESTROY = sub { $_[0]->discard_changes };
- my $artist = $schema->resultset("Artist")->create( {
+ my $artist = $schema->resultset("Artist")->create( {
artistid => 10,
name => "artist number 10",
});
is( $cd->year->year, 1998, 'updated year, bypassing inflation' );
-is( $cd->year->month, 1, 'month is still 1' );
+is( $cd->year->month, 1, 'month is still 1' );
# get_inflated_column test
$schema = DBICTest::Schema->connect($dsn, $user, $pass, {
quote_char => '"',
- name_sep => '.',
+ name_sep => '.',
on_connect_call => [ 'datetime_setup' ],
});
my $row;
ok( $row = $rs->create({
id => 1,
- starts_at => $date_only,
+ starts_at => $date_only,
created_on => $dt,
}));
ok( $row = $rs->search({ id => 1 }, { select => [qw/starts_at created_on/] })
# clean up our mess
sub cleanup {
- my $dbh;
+ my $dbh;
eval {
$schema->storage->disconnect; # to avoid object FOO is in use errors
$dbh = $schema->storage->dbh;
my $row;
ok( $row = $rs->create({
id => 1,
- starts_at => $date_only,
+ starts_at => $date_only,
created_on => $dt,
}));
ok( $row = $rs->search({ id => 1 }, { select => [qw/starts_at created_on/] })
# clean up our mess
sub cleanup {
- my $dbh;
+ my $dbh;
eval {
$dbh = $schema->storage->dbh;
};
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
on_connect_call => 'datetime_setup',
});
- my $sg = Scope::Guard->new(\&cleanup);
+ my $sg = Scope::Guard->new(\&cleanup);
eval { $schema->storage->dbh->do('DROP TABLE event') };
$schema->storage->dbh->do(<<"SQL");
}
# sometimes for ultra-mega-speed you want to fetch columns in esoteric ways
-# check the inflator over a non-fetching join
+# check the inflator over a non-fetching join
$rs_dbic = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
prefetch => { cds => 'tracks' },
order_by => [qw/cds.cdid tracks.trackid/],
#======= testing hashref serialization
-my $object = $rs->create( {
+my $object = $rs->create( {
serialized => '',
} );
ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
ok($inflated = $object->serialized, 'hashref inflation');
is_deeply($inflated, $struct_hash, 'inflated hash matches original');
-$object = $rs->create( {
+$object = $rs->create( {
serialized => '',
} );
$object->set_inflated_column('serialized', $struct_hash);
use Test::More;
use DBIC::SqlMakerTest;
-
+
my ($sql, @bind) = $schema->storage->sql_maker->select(%args);
is_same_sql_bind(
- $sql, \@bind,
+ $sql, \@bind,
$expected_sql, \@expected_bind,
'foo bar works'
);
=head2 is_same_bind
is_same_bind(
- \@given_bind,
+ \@given_bind,
\@expected_bind,
$test_msg
);
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest;
use strict;
use lib qw(t/lib);
use DBICTest;
use Test::More;
-
+
my $schema = DBICTest->init_schema();
=head1 DESCRIPTION
-This module provides the basic utilities to write tests against
+This module provides the basic utilities to write tests against
DBIx::Class.
=head1 METHODS
},
);
-This method removes the test SQLite database in t/var/DBIxClass.db
+This method removes the test SQLite database in t/var/DBIxClass.db
and then creates a new, empty database.
-This method will call deploy_schema() by default, unless the
+This method will call deploy_schema() by default, unless the
no_deploy flag is set.
-Also, by default, this method will call populate_schema() by
+Also, by default, this method will call populate_schema() by
default, unless the no_deploy or no_populate flags are set.
=cut
DBICTest->deploy_schema( $schema );
-This method does one of two things to the schema. It can either call
-the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment
-variable is set, otherwise the default is to read in the t/lib/sqlite.sql
-file and execute the SQL within. Either way you end up with a fresh set
+This method does one of two things to the schema. It can either call
+the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment
+variable is set, otherwise the default is to read in the t/lib/sqlite.sql
+file and execute the SQL within. Either way you end up with a fresh set
of tables for testing.
=cut
my $schema = shift;
my $args = shift || {};
- if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
+ if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
$schema->deploy($args);
} else {
my $filename = Path::Class::File->new(__FILE__)->dir
DBICTest->populate_schema( $schema );
-After you deploy your schema you can use this method to populate
+After you deploy your schema you can use this method to populate
the tables with test data.
=cut
[ 1, 2 ],
[ 1, 3 ],
]);
-
+
$schema->populate('TreeLike', [
[ qw/id parent name/ ],
[ 1, undef, 'root' ],
[ 1, "Tools" ],
[ 2, "Body Parts" ],
]);
-
+
$schema->populate('TypedObject', [
[ qw/objectid type value/ ],
[ 1, "pointy", "Awl" ],
# belongs to t/run/90ensure_class_loaded.tl
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::ErrorComponent;
use warnings;
use strict;
# belongs to t/run/90ensure_class_loaded.tl
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::FakeComponent;
use warnings;
use strict;
# belongs to t/05components.t
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::ForeignComponent;
use warnings;
use strict;
# belongs to t/run/90ensure_class_loaded.tl
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::OptionalComponent;
use warnings;
use strict;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::ResultSetManager;
use base 'DBIx::Class::Schema';
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::ResultSetManager::Foo;
use base 'DBIx::Class::Core';
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Artist;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::ArtistGUID;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::ArtistUndirectedMap;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::BindType;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::BooksInLibrary;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::CD;
use base qw/DBICTest::BaseResult/;
data_type => 'varchar',
size => 100,
},
- 'genreid' => {
+ 'genreid' => {
data_type => 'integer',
is_nullable => 1,
accessor => undef,
__PACKAGE__->set_primary_key('cdid');
__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
-__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
- is_deferrable => 1,
+__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
+ is_deferrable => 1,
proxy => { artist_name => 'name' },
});
-__PACKAGE__->belongs_to( very_long_artist_relationship => 'DBICTest::Schema::Artist', 'artist', {
- is_deferrable => 1,
+__PACKAGE__->belongs_to( very_long_artist_relationship => 'DBICTest::Schema::Artist', 'artist', {
+ is_deferrable => 1,
});
# in case this is a single-cd it promotes a track from another cd
-__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track',
- { join_type => 'left'}
+__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track',
+ { join_type => 'left'}
);
__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::CD_to_Producer;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Collection;
use base qw/DBICTest::BaseResult/;
{ where => { "object.type" => "pointy" } }
);
__PACKAGE__->many_to_many( round_objects => collection_object => "object",
- { where => { "object.type" => "round" } }
+ { where => { "object.type" => "round" } }
);
1;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::CollectionObject;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::ComputedColumn;
# for sybase and mssql computed column tests
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::CustomSql;
use base qw/DBICTest::Schema::Artist/;
__PACKAGE__->table('dummy');
__PACKAGE__->result_source_instance->name(\<<SQL);
- ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year
+ ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year
FROM artist a
JOIN cd ON cd.artist = a.artistid
WHERE cd.year = ?)
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Employee;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::FourKeys;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::FourKeys_to_TwoKeys;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Image;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::LinerNotes;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Lyrics;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Money;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::NoPrimaryKey;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::OneKey;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Owners;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Producer;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::PunctuatedColumnName;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::SelfRef;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::SelfRefAlias;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::SequenceTest;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Serialized;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Tag;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::TimestampPrimaryKey;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::TreeLike;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::TwoKeyTreeLike;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::TypedObject;
use base qw/DBICTest::BaseResult/;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Schema::Year1999CDs;
## Used in 104view.t
# belongs to t/run/90ensure_class_loaded.tl
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::SyntaxErrorComponent1;
use warnings;
use strict;
# belongs to t/run/90ensure_class_loaded.tl
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::SyntaxErrorComponent2;
use warnings;
use strict;
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Taint::Classes::Auto;
use base 'DBIx::Class::Core';
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Taint::Classes::Manual;
use base 'DBIx::Class::Core';
-package # hide from PAUSE
+package # hide from PAUSE
DBICTest::Taint::Namespaces::Result::Test;
use base 'DBIx::Class::Core';
---
+--
-- Created by SQL::Translator::Producer::SQLite
-- Created on Sat Jun 11 00:39:51 2011
---
+--
--
-- Table: artist
# even if the preceeding relationship already exists.
#
# To get this to work a minor rewrite of find() is necessary, and
-# more importantly some sort of recursive_insert() call needs to
+# more importantly some sort of recursive_insert() call needs to
# be available. The way things will work then is:
# *) while traversing the hierarchy code calls find_or_create()
# *) this in turn calls find(%\nested_dataset)
my $schema = DBICTest->init_schema();
-# Test various new() invocations - this is all about backcompat, making
+# Test various new() invocations - this is all about backcompat, making
# sure that insert() still works as expected by legacy code.
#
# What we essentially do is multi-instantiate objects, making sure nothing
lives_ok ( sub {
my $cd = $schema->resultset('CD')->create({
- artist => {
- name => 'Fred Bloggs'
+ artist => {
+ name => 'Fred Bloggs'
},
title => 'Some CD',
year => 1996
}, 'Test might_have again but with just a PK and FK (neither specified) in the mid-table');
lives_ok ( sub {
- my $newartist2 = $schema->resultset('Artist')->find_or_create({
+ my $newartist2 = $schema->resultset('Artist')->find_or_create({
name => 'Fred 3',
cds => [
- {
+ {
title => 'Noah Act',
year => 2007,
},
lives_ok ( sub {
my $artist = $schema->resultset('Artist')->first;
-
+
my $cd_result = $artist->create_related('cds', {
-
+
title => 'TestOneCD1',
year => 2007,
tracks => [
],
});
-
+
isa_ok( $cd_result, 'DBICTest::CD', "Got Good CD Class");
ok( $cd_result->title eq "TestOneCD1", "Got Expected Title");
-
+
my $tracks = $cd_result->tracks;
-
+
isa_ok( $tracks, 'DBIx::Class::ResultSet', 'Got Expected Tracks ResultSet');
-
+
foreach my $track ($tracks->all)
{
isa_ok( $track, 'DBICTest::Track', 'Got Expected Track Class');
lives_ok ( sub {
my $artist = $schema->resultset('Artist')->first;
-
+
my $cd_result = $artist->create_related('cds', {
-
+
title => 'TestOneCD2',
year => 2007,
tracks => [
liner_notes => { notes => 'I can haz liner notes?' },
});
-
+
isa_ok( $cd_result, 'DBICTest::CD', "Got Good CD Class");
ok( $cd_result->title eq "TestOneCD2", "Got Expected Title");
ok( $cd_result->notes eq 'I can haz liner notes?', 'Liner notes');
-
+
my $tracks = $cd_result->tracks;
-
+
isa_ok( $tracks, 'DBIx::Class::ResultSet', "Got Expected Tracks ResultSet");
-
+
foreach my $track ($tracks->all)
{
isa_ok( $track, 'DBICTest::Track', 'Got Expected Track Class');
$a = $schema->resultset('Artist')->find({name => 'Kurt Cobain'});
is($a->name, 'Kurt Cobain', 'Artist insertion ok');
- is($a->cds && $a->cds->first && $a->cds->first->title,
+ is($a->cds && $a->cds->first && $a->cds->first->title,
'In Utero', 'CD insertion ok');
}, 'populate');
## Create foreign key col obj including PK
## See test 20 in 66relationships.t
lives_ok ( sub {
- my $new_cd_hashref = {
- cdid => 27,
- title => 'Boogie Woogie',
- year => '2007',
+ my $new_cd_hashref = {
+ cdid => 27,
+ title => 'Boogie Woogie',
+ year => '2007',
artist => { artistid => 17, name => 'king luke' }
};
}, 'Create foreign key col obj including PK');
lives_ok ( sub {
- $schema->resultset("CD")->create({
- cdid => 28,
- title => 'Boogie Wiggle',
- year => '2007',
+ $schema->resultset("CD")->create({
+ cdid => 28,
+ title => 'Boogie Wiggle',
+ year => '2007',
artist => { artistid => 18, name => 'larry' }
});
}, 'new cd created without clash on related artist');
plan tests => 23;
-# an insane multicreate
+# an insane multicreate
# (should work, despite the fact that no one will probably use it this way)
my $schema = DBICTest->init_schema();
name => 'bob',
producer_to_cd => [
{
- cd => {
+ cd => {
artist => {
name => 'lars',
cds => [
},
},
{
- cd => {
+ cd => {
artist => {
name => 'lars', # should already exist
# even though the artist 'name' is not uniquely constrained
- # find_or_create will arguably DWIM
+ # find_or_create will arguably DWIM
},
title => 'Greatest hits 7',
year => 2013,
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
# The current artwork belongs to a cd by artist1
# but the artwork itself is painted by artist2
#
-# What we try is all possible permutations of join/prefetch
+# What we try is all possible permutations of join/prefetch
# combinations in both directions, while always expecting to
# arrive at the specific artist at the end of each path.
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
# test for partial prefetch via columns attr
my $cd = $schema->resultset('CD')->find(1,
{
- columns => [qw/title artist artist.name/],
+ columns => [qw/title artist artist.name/],
join => { 'artist' => {} }
}
);
'Tree search_related with prefetch ok');
$tree_like = eval { $schema->resultset('TreeLike')->search(
- { 'children.id' => 3, 'children_2.id' => 6 },
+ { 'children.id' => 3, 'children_2.id' => 6 },
{ join => [qw/children children children/] }
)->search_related('children', { 'children_4.id' => 7 }, { prefetch => 'children' }
)->first->children->first; };
$track = $schema->resultset("Track")->new( {} );
$track->cd;
-$track->set_from_related( cd => $cd );
+$track->set_from_related( cd => $cd );
ok ($track->cd, 'set_from_related ok after using the accessor' );
# update_from_related, the same as set_from_related, but it calls update afterwards
is($newartist->name, 'Random Boy Band Two', 'find_or_new_related new artist record with id');
is($newartist->id, 200, 'find_or_new_related new artist id set');
-lives_ok(
- sub {
+lives_ok(
+ sub {
my $new_bookmark = $schema->resultset("Bookmark")->new_result( {} );
my $new_related_link = $new_bookmark->new_related( 'link', {} );
},
$cd->add_to_producers({ name => 'Jack Black' });
is( $prod_rs->count(), 2, 'many_to_many add_to_$rel($hash) count ok' );
$cd->set_producers($schema->resultset('Producer')->all);
-is( $cd->producers->count(), $prod_before_count+2,
+is( $cd->producers->count(), $prod_before_count+2,
'many_to_many set_$rel(@objs) count ok' );
$cd->set_producers($schema->resultset('Producer')->find(1));
is( $cd->producers->count(), 1, 'many_to_many set_$rel($obj) count ok' );
$cd->set_producers([$schema->resultset('Producer')->all]);
-is( $cd->producers->count(), $prod_before_count+2,
+is( $cd->producers->count(), $prod_before_count+2,
'many_to_many set_$rel(\@objs) count ok' );
$cd->set_producers([$schema->resultset('Producer')->find(1)]);
is( $cd->producers->count(), 1, 'many_to_many set_$rel([$obj]) count ok' );
my $relinfo_with_attr = $rs_overridden->relationship_info ('cd_3');
cmp_ok($relinfo_with_attr->{attrs}{is_foreign_key_constraint}, '==', 0, "is_foreign_key_constraint defined for belongs_to relationships with attr.");
-# check that relationships below left join relationships are forced to left joins
+# check that relationships below left join relationships are forced to left joins
# when traversing multiple belongs_to
my $cds = $schema->resultset("CD")->search({ 'me.cdid' => 5 }, { join => { single_track => 'cd' } });
is($cds->count, 1, "subjoins under left joins force_left (string)");
is_same_sql (
$search_sql,
'SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
- FROM cd me
+ FROM cd me
WHERE ( me.artist = ? AND me.title = ? AND me.genreid = ? )
',
'expected select issued',
is_same_sql_bind (
$book_rs->as_subselect_rs->as_query,
- '(SELECT me.id, me.source, me.owner, me.title, me.price
+ '(SELECT me.id, me.source, me.owner, me.title, me.price
FROM (
SELECT me.id, me.source, me.owner, me.title, me.price
FROM books me
$new_source->source_name('Complex');
$new_source->name(\<<'');
- ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year
+ ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year
FROM artist a
JOIN cd ON cd.artist = a.artistid
WHERE cd.year = ?)
$rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM (SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year FROM artist a JOIN cd ON cd.artist = a.artistid WHERE cd.year = ?) me WHERE title LIKE ?)",
[
- [ {} => '1999' ],
+ [ {} => '1999' ],
[ {} => 'Spoon%' ]
],
'got correct SQL'
$rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM (SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year FROM artist a JOIN cd ON cd.artist = a.artistid WHERE cd.year = ?) me WHERE title LIKE ?)",
[
- [ {} => '1999' ],
+ [ {} => '1999' ],
[ {} => 'Spoon%' ]
],
'got correct SQL (cookbook arbitrary SQL, in separate file)'
# More complicated ordering
{
- my $ordered = $rs->search(undef, {
+ my $ordered = $rs->search(undef, {
order_by => [
- { -asc => 'artistid' },
+ { -asc => 'artistid' },
{ -desc => 'name' },
- ]
+ ]
});
ok $ordered->is_ordered, 'more complicated resultset ordering is_ordered';
}
is_deeply (
[ $tkfks->search ({ autopilot => [qw/a b x y/]}, { order_by => 'autopilot' })
- ->get_column ('pilot_sequence')->all
+ ->get_column ('pilot_sequence')->all
],
[qw/11 21 30 40/],
'Only two rows incremented',
is_deeply (
[ $tkfks->search ({ autopilot => [qw/a b x y/]}, { order_by => 'autopilot' })
- ->get_column ('pilot_sequence')->all
+ ->get_column ('pilot_sequence')->all
],
[qw/12 22 30 40/],
'Only two rows incremented (where => scalarref works)',
'+select' => ['owner.name'],
'+as' => ['owner_name'],
join => 'owner',
- rows => 1
+ rows => 1
});
is_same_sql_bind( $rs_selectas_top->search({})->as_query,
[owner].[name],
( SELECT COUNT(*) FROM
( SELECT FIRST ? [owner].[id] FROM [owners] [owner]
- WHERE [count].[id] = [owner].[id] and [count].[name] = ?
+ WHERE [count].[id] = [owner].[id] and [count].[name] = ?
) [owner]
)
FROM [books] [me]
[owner].[name],
( SELECT COUNT(*) FROM
( SELECT FIRST ? [owner].[id] FROM [owners] [owner]
- WHERE [count].[id] = [owner].[id] and [count].[name] = ?
+ WHERE [count].[id] = [owner].[id] and [count].[name] = ?
) [owner]
)
FROM [books] [me]
use DBIx::Class::SQLMaker::Oracle;
#
-# Offline test for connect_by
+# Offline test for connect_by
# ( without active database connection)
#
my @handle_tests = (
bind => ['King'],
msg => 'oracle.com example #1',
},
- # CONNECT BY PRIOR employee_id = manager_id and
+ # CONNECT BY PRIOR employee_id = manager_id and
# PRIOR account_mgr_id = customer_id ...
{
connect_by => {
}
)->as_query,
"(
- SELECT me.foo, me.bar, me.hello, me.goodbye, me.sensors, me.read_count
- FROM fourkeys me
- WHERE ( foo = ? )
+ SELECT me.foo, me.bar, me.hello, me.goodbye, me.sensors, me.read_count
+ FROM fourkeys me
+ WHERE ( foo = ? )
HAVING read_count > ? OR read_count < ?
ORDER BY $args->{order_req}
)",
die "$$ starts in txn!" if $s->storage->transaction_depth != 0;
$s->txn_do ( sub {
die "$$ not in txn!" if $s->storage->transaction_depth == 0;
- $s->storage->dbh->do('SELECT 1') }
+ $s->storage->dbh->do('SELECT 1') }
);
die "$$ did not finish txn!" if $s->storage->transaction_depth != 0;
},
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use lib 't/lib';
use DBICTest;
-# Don't run tests for installs
-if ( DBICTest::RunMode->is_plain ) {
- plan( skip_all => "Author tests not required for installation" );
-}
-
-plan skip_all => 'Test::EOL very broken';
-
require DBIx::Class;
unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_eol') ) {
my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_eol');
: plan skip_all => "Test needs: $missing"
}
-TODO: {
- local $TODO = 'Do not fix those yet - we have way too many branches out there, merging will be hell';
- Test::EOL::all_perl_files_ok({ trailing_whitespace => 1},
- qw/t xt lib script/,
- DBICTest::RunMode->is_author ? ('maint') : (),
- );
-}
+Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 },
+ qw/t xt lib script/,
+ DBICTest::RunMode->is_author ? ('maint') : (),
+);
-# FIXME - need to fix Test::EOL
+# FIXME - Test::EOL declares 'no_plan' which conflicts with done_testing
+# https://github.com/schwern/test-more/issues/14
#done_testing;
use lib 't/lib';
use DBICTest;
-# Don't run tests for installs
-if ( DBICTest::RunMode->is_plain ) {
- plan( skip_all => "Author tests not required for installation" );
-}
-
require DBIx::Class;
unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_notabs') ) {
my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_notabs');
DBICTest::RunMode->is_author ? ('maint') : (),
);
-# FIXME - need to fix Test::NoTabs - doesn't work with done_testing
+# FIXME - Test::NoTabs declares 'no_plan' which conflicts with done_testing
+# https://github.com/schwern/test-more/issues/14
#done_testing;
use lib qw(t/lib);
use DBICTest;
-# Don't run tests for installs
-if ( DBICTest::RunMode->is_plain ) {
- plan( skip_all => "Author tests not required for installation" );
-}
-
require DBIx::Class;
unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_pod') ) {
my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_pod');
use DBICTest;
use namespace::clean;
-# Don't run tests for installs
-if ( DBICTest::RunMode->is_plain ) {
- plan( skip_all => "Author tests not required for installation" );
-}
-
require DBIx::Class;
unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_podcoverage') ) {
my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_podcoverage');