[Bast-commits] r6586 - in DBIx-Class/0.08/branches/mystery_join: .
lib/DBIx/Class lib/DBIx/Class/InflateColumn
lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI t t/bind
t/lib/DBICTest t/prefetch
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Jun 10 11:00:03 GMT 2009
Author: ribasushi
Date: 2009-06-10 11:00:02 +0000 (Wed, 10 Jun 2009)
New Revision: 6586
Modified:
DBIx-Class/0.08/branches/mystery_join/
DBIx-Class/0.08/branches/mystery_join/Makefile.PL
DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/InflateColumn/DateTime.pm
DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI/Cursor.pm
DBIx-Class/0.08/branches/mystery_join/t/52cycle.t
DBIx-Class/0.08/branches/mystery_join/t/71mysql.t
DBIx-Class/0.08/branches/mystery_join/t/89inflate_datetime.t
DBIx-Class/0.08/branches/mystery_join/t/bind/bindtype_columns.t
DBIx-Class/0.08/branches/mystery_join/t/lib/DBICTest/AuthorCheck.pm
DBIx-Class/0.08/branches/mystery_join/t/prefetch/rows_bug.t
Log:
r6553 at Thesaurus (orig r6552): ribasushi | 2009-06-08 23:56:41 +0200
duh
r6557 at Thesaurus (orig r6556): ash | 2009-06-09 12:20:34 +0200
Addjust bug to show problem with rows => 1 + child rel
r6558 at Thesaurus (orig r6557): ribasushi | 2009-06-09 13:12:46 +0200
Require a recent bugfixed Devel::Cycle
r6560 at Thesaurus (orig r6559): ash | 2009-06-09 15:07:30 +0200
Make IC::DT extra warning state the column name too
r6575 at Thesaurus (orig r6574): ribasushi | 2009-06-10 00:19:48 +0200
AuthorCheck fixes
r6579 at Thesaurus (orig r6578): ribasushi | 2009-06-10 00:52:17 +0200
r6522 at Thesaurus (orig r6521): ribasushi | 2009-06-05 19:27:55 +0200
New branch to try resultsource related stuff
r6545 at Thesaurus (orig r6544): ribasushi | 2009-06-08 13:00:54 +0200
First stab at adding resultsources to each join in select - works won-der-ful-ly
r6546 at Thesaurus (orig r6545): ribasushi | 2009-06-08 13:14:08 +0200
Commit failing test and thoughts on search arg deflation
r6576 at Thesaurus (orig r6575): ribasushi | 2009-06-10 00:31:55 +0200
Todoify DT in search deflation test until after 0.09
r6577 at Thesaurus (orig r6576): ribasushi | 2009-06-10 00:48:07 +0200
Factor out the $ident resolver
r6581 at Thesaurus (orig r6580): ribasushi | 2009-06-10 01:21:50 +0200
Move as_query out of the cursor
r6582 at Thesaurus (orig r6581): ribasushi | 2009-06-10 01:27:19 +0200
Think before commit
r6583 at Thesaurus (orig r6582): ribasushi | 2009-06-10 09:37:19 +0200
Clarify and disable rows/prefetch test - fix is easy, but architecturally unsound - need more time
Property changes on: DBIx-Class/0.08/branches/mystery_join
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/diamond_relationships:6310
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/joined_count:6323
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/order_by_refactor:6475
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/top_limit_altfix:6429
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/diamond_relationships:6310
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/joined_count:6323
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/order_by_refactor:6475
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rsrc_in_storage:6577
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/top_limit_altfix:6429
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:6582
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/mystery_join/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/Makefile.PL 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/Makefile.PL 2009-06-10 11:00:02 UTC (rev 6586)
@@ -71,6 +71,7 @@
# t/52cycle.t
'Test::Memory::Cycle' => 0,
+ 'Devel::Cycle' => 1.10,
# t/60core.t
'DateTime::Format::MySQL' => 0,
Modified: DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -116,14 +116,14 @@
my $timezone;
if ( defined $info->{extra}{timezone} ) {
carp "Putting timezone into extra => { timezone => '...' } has been deprecated, ".
- "please put it directly into the columns definition.";
+ "please put it directly into the '$column' column definition.";
$timezone = $info->{extra}{timezone};
}
my $locale;
if ( defined $info->{extra}{locale} ) {
carp "Putting locale into extra => { locale => '...' } has been deprecated, ".
- "please put it directly into the columns definition.";
+ "please put it directly into the '$column' column definition.";
$locale = $info->{extra}{locale};
}
@@ -139,7 +139,7 @@
if (defined $info->{extra}{floating_tz_ok}) {
carp "Putting floating_tz_ok into extra => { floating_tz_ok => 1 } has been deprecated, ".
- "please put it directly into the columns definition.";
+ "please put it directly into the '$column' column definition.";
$info{floating_tz_ok} = $info->{extra}{floating_tz_ok};
}
Modified: DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSet.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSet.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -1925,7 +1925,10 @@
=cut
-sub as_query { return shift->cursor->as_query(@_) }
+sub as_query {
+ my $self = shift;
+ return $self->result_source->storage->as_query($self->_resolved_attrs);
+}
=head2 find_or_new
@@ -2428,7 +2431,11 @@
my $attrs = $self->{attrs};
my $from = $attrs->{from}
- || [ { $attrs->{alias} => $source->from } ];
+ || [ {
+ -result_source => $source,
+ -alias => $attrs->{alias},
+ $attrs->{alias} => $source->from,
+ } ];
my $seen = { %{$attrs->{seen_join} || {} } };
@@ -2533,7 +2540,11 @@
push( @{ $attrs->{as} }, @$adds );
}
- $attrs->{from} ||= [ { $self->{attrs}{alias} => $source->from } ];
+ $attrs->{from} ||= [ {
+ -result_source => $source,
+ -alias => $self->{attrs}{alias},
+ $self->{attrs}{alias} => $source->from,
+ } ];
if ( exists $attrs->{join} || exists $attrs->{prefetch} ) {
my $join = delete $attrs->{join} || {};
@@ -2614,7 +2625,7 @@
my $p = $paths;
$p = $p->{$_} ||= {} for @{$j->[0]{-join_path}};
- push @{$p->{-join_aliases} }, $j->[0]{-join_alias};
+ push @{$p->{-join_aliases} }, $j->[0]{-alias};
}
return $paths;
Modified: DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSource.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/ResultSource.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -1120,10 +1120,13 @@
$type = $rel_info->{attrs}{join_type} || '';
$force_left->{force} = 1 if lc($type) eq 'left';
}
- return [ { $as => $self->related_source($join)->from,
+
+ my $rel_src = $self->related_source($join);
+ return [ { $as => $rel_src->from,
+ -result_source => $rel_src,
-join_type => $type,
-join_path => [@$jpath, $join],
- -join_alias => $as,
+ -alias => $as,
-relation_chain_depth => $seen->{-relation_chain_depth} || 0,
},
$self->_resolve_condition($rel_info->{cond}, $as, $alias) ];
Modified: DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI/Cursor.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -49,32 +49,6 @@
return bless ($new, $class);
}
-=head2 as_query
-
-=over 4
-
-=item Arguments: none
-
-=item Return Value: \[ $sql, @bind ]
-
-=back
-
-Returns the SQL statement and bind vars associated with the invocant.
-
-=cut
-
-sub as_query {
- my $self = shift;
-
- my $storage = $self->{storage};
- my $sql_maker = $storage->sql_maker;
- local $sql_maker->{for};
-
- my @args = $storage->_select_args(@{$self->{args}});
- my ($sql, $bind) = $storage->_prep_for_execute(@args[0 .. 2], [@args[4 .. $#args]]);
- return \[ "($sql)", @{ $bind || [] }];
-}
-
=head2 next
=over 4
Modified: DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/lib/DBIx/Class/Storage/DBI.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -9,7 +9,7 @@
use DBI;
use DBIx::Class::Storage::DBI::Cursor;
use DBIx::Class::Storage::Statistics;
-use Scalar::Util qw/blessed weaken/;
+use Scalar::Util();
use List::Util();
__PACKAGE__->mk_group_accessors('simple' =>
@@ -717,7 +717,7 @@
if($dbh && !$self->unsafe) {
my $weak_self = $self;
- weaken($weak_self);
+ Scalar::Util::weaken($weak_self);
$dbh->{HandleError} = sub {
if ($weak_self) {
$weak_self->throw_exception("DBI Exception: $_[0]");
@@ -898,7 +898,7 @@
sub _prep_for_execute {
my ($self, $op, $extra_bind, $ident, $args) = @_;
- if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ if( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
$ident = $ident->from();
}
@@ -910,6 +910,38 @@
return ($sql, \@bind);
}
+=head2 as_query
+
+=over 4
+
+=item Arguments: $rs_attrs
+
+=item Return Value: \[ $sql, @bind ]
+
+=back
+
+Returns the SQL statement and bind vars that would result from the given
+ResultSet attributes (does not actually run a query)
+
+=cut
+
+sub as_query {
+ my ($self, $rs_attr) = @_;
+
+ my $sql_maker = $self->sql_maker;
+ local $sql_maker->{for};
+
+ # my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset) = $self->_select_args(...);
+ my @args = $self->_select_args($rs_attr->{from}, $rs_attr->{select}, $rs_attr->{where}, $rs_attr);
+
+ # my ($sql, $bind) = $self->_prep_for_execute($op, $bind, $ident, [ $select, $cond, $order, $rows, $offset ]);
+ my ($sql, $bind) = $self->_prep_for_execute(
+ @args[0 .. 2],
+ [ @args[4 .. $#args] ],
+ );
+ return \[ "($sql)", @{ $bind || [] }];
+}
+
sub _fix_bind_params {
my ($self, @bind) = @_;
@@ -931,7 +963,7 @@
if ( $self->debug ) {
@bind = $self->_fix_bind_params(@bind);
-
+
$self->debugobj->query_start( $sql, @bind );
}
}
@@ -990,7 +1022,7 @@
sub insert {
my ($self, $source, $to_insert) = @_;
-
+
my $ident = $source->from;
my $bind_attributes = $self->source_bind_attributes($source);
@@ -1092,7 +1124,7 @@
my $self = shift @_;
my $source = shift @_;
- my $bind_attrs = {}; ## If ever it's needed...
+ my $bind_attrs = $self->source_bind_attributes($source);
return $self->_execute('delete' => [], $source, $bind_attrs, @_);
}
@@ -1207,7 +1239,31 @@
(qw/order_by group_by having _virtual_order_by/ )
};
- my $bind_attrs = {}; ## Future support
+
+ my $bind_attrs = {};
+
+ my $alias2source = $self->_resolve_ident_sources ($ident);
+
+ for my $alias (keys %$alias2source) {
+ my $bindtypes = $self->source_bind_attributes ($alias2source->{$alias}) || {};
+ for my $col (keys %$bindtypes) {
+
+ my $fqcn = join ('.', $alias, $col);
+ $bind_attrs->{$fqcn} = $bindtypes->{$col} if $bindtypes->{$col};
+
+ # so that unqualified searches can be bound too
+ $bind_attrs->{$col} = $bind_attrs->{$fqcn} if $alias eq 'me';
+ }
+ }
+
+ # This would be the point to deflate anything found in $condition
+ # (and leave $attrs->{bind} intact). Problem is - inflators historically
+ # expect a row object. And all we have is a resultsource (it is trivial
+ # to extract deflator coderefs via $alias2source above).
+ #
+ # I don't see a way forward other than changing the way deflators are
+ # invoked, and that's just bad...
+
my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order);
if ($attrs->{software_limit} ||
$sql_maker->_default_limit_syntax eq "GenericSubQ") {
@@ -1223,6 +1279,35 @@
return @args;
}
+sub _resolve_ident_sources {
+ my ($self, $ident) = @_;
+
+ my $alias2source = {};
+
+ # the reason this is so contrived is that $ident may be a {from}
+ # structure, specifying multiple tables to join
+ if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ $alias2source->{$ident->alias} = $ident;
+ }
+ elsif (ref $ident eq 'ARRAY') {
+
+ for (@$ident) {
+ my $tabinfo;
+ if (ref $_ eq 'HASH') {
+ $tabinfo = $_;
+ }
+ if (ref $_ eq 'ARRAY' and ref $_->[0] eq 'HASH') {
+ $tabinfo = $_->[0];
+ }
+
+ $alias2source->{$tabinfo->{-alias}} = $tabinfo->{-result_source}
+ if ($tabinfo->{-result_source});
+ }
+ }
+
+ return $alias2source;
+}
+
sub count {
my ($self, $source, $attrs) = @_;
Modified: DBIx-Class/0.08/branches/mystery_join/t/52cycle.t
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/52cycle.t 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/52cycle.t 2009-06-10 11:00:02 UTC (rev 6586)
@@ -5,9 +5,9 @@
use lib qw(t/lib);
BEGIN {
- eval { require Test::Memory::Cycle };
- if ($@) {
- plan skip_all => "leak test needs Test::Memory::Cycle";
+ eval { require Test::Memory::Cycle; require Devel::Cycle };
+ if ($@ or Devel::Cycle->VERSION < 1.10) {
+ plan skip_all => "leak test needs Test::Memory::Cycle and Devel::Cycle >= 1.10";
} else {
plan tests => 1;
}
Modified: DBIx-Class/0.08/branches/mystery_join/t/71mysql.t
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/71mysql.t 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/71mysql.t 2009-06-10 11:00:02 UTC (rev 6586)
@@ -114,7 +114,7 @@
# (mysql doesn't seem to like subqueries with equally named columns)
#
-SKIP: {
+{
# try a ->has_many direction (due to a 'multi' accessor the select/group_by group is collapsed)
my $owners = $schema->resultset ('Owners')->search (
{ 'books.id' => { '!=', undef }},
@@ -126,7 +126,7 @@
is ($_->count, 2, 'Prefetched grouped search returns correct count');
}
- # try a ->prefetch direction (no select collapse)
+ # try a ->belongs_to direction (no select collapse)
my $books = $schema->resultset ('BooksInLibrary')->search (
{ 'owner.name' => 'wiggle' },
{ prefetch => 'owner', distinct => 1 }
Modified: DBIx-Class/0.08/branches/mystery_join/t/89inflate_datetime.t
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/89inflate_datetime.t 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/89inflate_datetime.t 2009-06-10 11:00:02 UTC (rev 6586)
@@ -13,7 +13,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 53;
+plan tests => 57;
SKIP: {
eval { require DateTime::Format::MySQL };
@@ -29,6 +29,18 @@
my $starts = $event->starts_at;
is("$starts", '2006-04-25T22:24:33', 'Correct date/time');
+TODO: {
+ local $TODO = "We can't do this yet before 0.09" if DBIx::Class->VERSION < 0.09;
+
+ ok(my $row =
+ $schema->resultset('Event')->search({ starts_at => $starts })->single);
+ is(eval { $row->id }, 1, 'DT in search');
+
+ ok($row =
+ $schema->resultset('Event')->search({ starts_at => { '>=' => $starts } })->single);
+ is(eval { $row->id }, 1, 'DT in search with condition');
+}
+
# create using DateTime
my $created = $schema->resultset('Event')->create({
starts_at => DateTime->new(year=>2006, month=>6, day=>18),
Modified: DBIx-Class/0.08/branches/mystery_join/t/bind/bindtype_columns.t
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/bind/bindtype_columns.t 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/bind/bindtype_columns.t 2009-06-10 11:00:02 UTC (rev 6586)
@@ -49,10 +49,7 @@
is($row->get_column('bytea'), $big_long_string, "Created the blob correctly.");
}
-TODO: {
- local $TODO =
- 'Passing bind attributes to $sth->bind_param() should be implemented (it only works in $storage->insert ATM)';
-
+{
my $rs = $schema->resultset('BindType')->search({ bytea => $big_long_string });
# search on the bytea column (select)
Modified: DBIx-Class/0.08/branches/mystery_join/t/lib/DBICTest/AuthorCheck.pm
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/lib/DBICTest/AuthorCheck.pm 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/lib/DBICTest/AuthorCheck.pm 2009-06-10 11:00:02 UTC (rev 6586)
@@ -84,7 +84,7 @@
sub _find_co_root {
my @mod_parts = split /::/, (__PACKAGE__ . '.pm');
- my $rel_path = file (@mod_parts);
+ my $rel_path = join ('/', @mod_parts); # %INC stores paths with / regardless of OS
return undef unless ($INC{$rel_path});
@@ -93,7 +93,7 @@
# - do 'cd ..' as many times as necessary to get to t/lib/../..
my $root = dir ($INC{$rel_path});
- for (0 .. @mod_parts + 1) {
+ for (1 .. @mod_parts + 2) {
$root = $root->parent;
}
Modified: DBIx-Class/0.08/branches/mystery_join/t/prefetch/rows_bug.t
===================================================================
--- DBIx-Class/0.08/branches/mystery_join/t/prefetch/rows_bug.t 2009-06-10 09:22:05 UTC (rev 6585)
+++ DBIx-Class/0.08/branches/mystery_join/t/prefetch/rows_bug.t 2009-06-10 11:00:02 UTC (rev 6586)
@@ -7,7 +7,8 @@
use lib qw(t/lib);
use DBICTest;
-plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 2);
+plan skip_all => 'fix pending';
+#plan tests => 4;
my $schema = DBICTest->init_schema();
my $no_prefetch = $schema->resultset('Artist')->search(
@@ -23,61 +24,45 @@
}
);
-my $no_prefetch_count = 0;
-my $use_prefetch_count = 0;
-
is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
+is(
+ scalar ($no_prefetch->all),
+ scalar ($use_prefetch->all),
+ "Amount of returned rows is right"
+);
-TODO: {
- local $TODO = "This is a difficult bug to fix, workaround is not to use prefetch with rows";
- $no_prefetch_count++ while $no_prefetch->next;
- $use_prefetch_count++ while $use_prefetch->next;
- is(
- $no_prefetch_count,
- $use_prefetch_count,
- "manual row count confirms consistency"
- . " (\$no_prefetch_count == $no_prefetch_count, "
- . " \$use_prefetch_count == $use_prefetch_count)"
- );
-}
-__END__
-The fix is to, when using prefetch, take the query and put it into a subquery
-joined to the tables we're prefetching from. This might result in the same
-table being joined once in the main subquery and once in the main query. This
-may actually resolve other, unknown edgecase bugs. It is also the right way
-to do prefetching. Optimizations can come later.
-This means that:
- $foo_rs->search(
- { ... },
- {
- prefetch => 'bar',
- ...
- },
- );
+my $artist_many_cds = $schema->resultset('Artist')->search ( {}, {
+ join => 'cds',
+ group_by => 'me.artistid',
+ having => \ 'count(cds.cdid) > 1',
+})->first;
-becomes:
- my $temp = $foo_rs->search(
- { ... },
- {
- join => 'bar',
- ...
- },
- );
- $foo_rs->storage->schema->resultset('foo')->search(
- undef,
- {
- from => [
- { me => $temp->as_query },
- ],
- prefetch => 'bar',
- },
- );
-Problem:
- * The prefetch->join change needs to happen ONLY IF there are conditions
- that depend on bar being joined.
- * How will this work when the $rs is further searched on? Those clauses
- need to be added to the subquery, not the outer one. This is particularly
- true if rows is added in the attribute later per the Pager.
+$no_prefetch = $schema->resultset('Artist')->search(
+ { artistid => $artist_many_cds->id },
+ { rows => 1 }
+);
+
+$use_prefetch = $schema->resultset('Artist')->search(
+ { artistid => $artist_many_cds->id },
+ {
+ prefetch => 'cds',
+ rows => 1
+ }
+);
+
+my $prefetch_artist = $use_prefetch->first;
+my $normal_artist = $no_prefetch->first;
+
+is(
+ $prefetch_artist->cds->count,
+ $normal_artist->cds->count,
+ "Count of child rel with prefetch + rows => 1 is right"
+);
+is (
+ scalar ($prefetch_artist->cds->all),
+ scalar ($normal_artist->cds->all),
+ "Amount of child rel rows with prefetch + rows => 1 is right"
+);
More information about the Bast-commits
mailing list