[Bast-commits] r6577 - in DBIx-Class/0.08/branches/rsrc_in_storage: . lib/DBIx/Class lib/DBIx/Class/InflateColumn lib/DBIx/Class/Relationship lib/DBIx/Class/SQLAHacks lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI t t/lib/DBICTest t/lib/DBICTest/Schema t/multi_create t/prefetch

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Tue Jun 9 22:48:29 GMT 2009


Author: ribasushi
Date: 2009-06-09 22:48:29 +0000 (Tue, 09 Jun 2009)
New Revision: 6577

Added:
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/MySQL.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/t/18insert_default.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/
   DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/insert_defaults.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/m2m.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/reentrance_count.t
Removed:
   DBIx-Class/0.08/branches/rsrc_in_storage/t/96multi_create/
Modified:
   DBIx-Class/0.08/branches/rsrc_in_storage/
   DBIx-Class/0.08/branches/rsrc_in_storage/Changes
   DBIx-Class/0.08/branches/rsrc_in_storage/Makefile.PL
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/InflateColumn/DateTime.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Relationship/ManyToMany.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/ResultSet.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/OracleJoins.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI/mysql.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/Statistics.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/t/03podcoverage.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/52cycle.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/71mysql.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/86sqlt.t
   DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/AuthorCheck.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Bookmark.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Link.pm
   DBIx-Class/0.08/branches/rsrc_in_storage/t/prefetch/rows_bug.t
Log:
 r6511 at Thesaurus (orig r6510):  ribasushi | 2009-06-04 23:51:13 +0200
 It seems that this localisation can lead to problems
 Unfortunately no test case as the trigger was buried deep within Reaction, I coulnd't figure out an isolation
 r6519 at Thesaurus (orig r6518):  ribasushi | 2009-06-05 16:28:58 +0200
 This was dumb - of course I want a copy
 Otherwise the next serach_related will work with a contaminated seen_joins
 r6521 at Thesaurus (orig r6520):  ribasushi | 2009-06-05 19:25:56 +0200
 Factor out the grouped count subquery SELECTor so specific storage classes can override it
 Trim attribute deletion lists - we work with _resolved_attrs - +X are already folded into X and the like
 r6529 at Thesaurus (orig r6528):  ribasushi | 2009-06-06 10:45:10 +0200
 rename MC test dir
 r6530 at Thesaurus (orig r6529):  ribasushi | 2009-06-06 10:47:47 +0200
 TODOified reentrancy counter - this shall be used to optimize MC some day
 r6531 at Thesaurus (orig r6530):  ribasushi | 2009-06-06 10:50:56 +0200
 Port another forgotten MC fix
 r6538 at Thesaurus (orig r6537):  ribasushi | 2009-06-07 23:07:55 +0200
 Fix for mysql subquery problem
 r6539 at Thesaurus (orig r6538):  ribasushi | 2009-06-07 23:36:43 +0200
 Make empty/default inserts use standard SQL
 r6540 at Thesaurus (orig r6539):  ribasushi | 2009-06-08 00:59:21 +0200
 Add mysql empty insert SQL override
 Make SQLAHacks parts loadable at runtime via ensure_class_loaded
 r6541 at Thesaurus (orig r6540):  ribasushi | 2009-06-08 01:03:04 +0200
 Make podcoverage happy
 r6542 at Thesaurus (orig r6541):  ribasushi | 2009-06-08 01:24:06 +0200
 Fix find_or_new/create to stop returning random rows when default value insert is requested
 r6543 at Thesaurus (orig r6542):  ribasushi | 2009-06-08 11:36:56 +0200
 Simply order_by/_virtual_order_by handling
 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



Property changes on: DBIx-Class/0.08/branches/rsrc_in_storage
___________________________________________________________________
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/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:6574
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/rsrc_in_storage/Changes
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/Changes	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/Changes	2009-06-09 22:48:29 UTC (rev 6577)
@@ -8,6 +8,9 @@
           an exception
         - fixed corner case when populate() erroneously falls back to
           create()
+        - work around braindead mysql when doing subquery counts on
+          resultsets containing identically named columns from several
+          tables
 
 0.08103 2009-05-26 19:50:00 (UTC)
         - Multiple $resultset -> count/update/delete fixes. Now any

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/Makefile.PL	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/Makefile.PL	2009-06-09 22:48:29 UTC (rev 6577)
@@ -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/rsrc_in_storage/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/InflateColumn/DateTime.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/InflateColumn/DateTime.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -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/rsrc_in_storage/lib/DBIx/Class/Relationship/ManyToMany.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Relationship/ManyToMany.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Relationship/ManyToMany.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -85,12 +85,12 @@
       my $obj;
       if (ref $_[0]) {
         if (ref $_[0] eq 'HASH') {
-          $obj = $f_rel_rs->create($_[0]);
+          $obj = $f_rel_rs->find_or_create($_[0]);
         } else {
           $obj = $_[0];
         }
       } else {
-        $obj = $f_rel_rs->create({@_});
+        $obj = $f_rel_rs->find_or_create({@_});
       }
 
       my $link_vals = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {};

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/ResultSet.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/ResultSet.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -661,7 +661,6 @@
   my ($self) = @_;
 
   my $attrs = $self->_resolved_attrs_copy;
-  $attrs->{_virtual_order_by} = $self->_gen_virtual_order;
 
   return $self->{cursor}
     ||= $self->result_source->storage->select($attrs->{from}, $attrs->{select},
@@ -714,7 +713,6 @@
   }
 
   my $attrs = $self->_resolved_attrs_copy;
-  $attrs->{_virtual_order_by} = $self->_gen_virtual_order;
 
   if ($where) {
     if (defined $attrs->{where}) {
@@ -742,16 +740,7 @@
   return (@data ? ($self->_construct_object(@data))[0] : undef);
 }
 
-# _gen_virtual_order
-#
-# This is a horrble hack, but seems like the best we can do at this point
-# Some limit emulations (Top) require an ordered resultset in order to 
-# function at all. So supply a PK order to be used if necessary
 
-sub _gen_virtual_order {
-  return [ shift->result_source->primary_columns ];
-}
-
 # _is_unique_query
 #
 # Try to determine if the specified query is guaranteed to be unique, based on
@@ -1329,7 +1318,7 @@
 
     my $subrs = (ref $self)->new($rsrc, $attrs);
 
-    return $self->result_source->storage->subq_update_delete($subrs, $op, $values);
+    return $self->result_source->storage->_subq_update_delete($subrs, $op, $values);
   }
   else {
     return $rsrc->storage->$op(
@@ -1977,8 +1966,10 @@
   my $self     = shift;
   my $attrs    = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {});
   my $hash     = ref $_[0] eq 'HASH' ? shift : {@_};
-  my $exists   = $self->find($hash, $attrs);
-  return defined $exists ? $exists : $self->new_result($hash);
+  if (keys %$hash and my $row = $self->find($hash, $attrs) ) {
+    return $row;
+  }
+  return $self->new_result($hash);
 }
 
 =head2 create
@@ -2108,8 +2099,10 @@
   my $self     = shift;
   my $attrs    = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {});
   my $hash     = ref $_[0] eq 'HASH' ? shift : {@_};
-  my $exists   = $self->find($hash, $attrs);
-  return defined $exists ? $exists : $self->create($hash);
+  if (keys %$hash and my $row = $self->find($hash, $attrs) ) {
+    return $row;
+  }
+  return $self->create($hash);
 }
 
 =head2 update_or_create
@@ -2441,7 +2434,7 @@
       $attrs->{alias} => $source->from,
     } ];
 
-  my $seen = { %{$attrs->{seen_join}||{}} };
+  my $seen = { %{$attrs->{seen_join} || {} } };
 
   # we need to take the prefetch the attrs into account before we
   # ->_resolve_join as otherwise they get lost - captainL
@@ -2579,6 +2572,14 @@
     $attrs->{order_by} = [];
   }
 
+  # If the order_by is otherwise empty - we will use this for TOP limit
+  # emulation and the like.
+  # Although this is needed only if the order_by is not defined, it is
+  # actually cheaper to just populate this rather than properly examining
+  # order_by (stuf like [ {} ] and the like)
+  $attrs->{_virtual_order_by} = [ $self->result_source->primary_columns ];
+
+
   my $collapse = $attrs->{collapse} || {};
   if ( my $prefetch = delete $attrs->{prefetch} ) {
     $prefetch = $self->_merge_attr( {}, $prefetch );

Added: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/MySQL.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/MySQL.pm	                        (rev 0)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/MySQL.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -0,0 +1,24 @@
+package # Hide from PAUSE
+  DBIx::Class::SQLAHacks::MySQL;
+
+use base qw( DBIx::Class::SQLAHacks );
+use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
+
+#
+# MySQL does not understand the standard INSERT INTO $table DEFAULT VALUES
+# Adjust SQL here instead
+#
+sub insert {
+  my $self = shift;
+
+  my $table = $_[0];
+  $table = $self->_quote($table) unless ref($table);
+
+  if (! $_[1] or (ref $_[1] eq 'HASH' and !keys %{$_[1]} ) ) {
+    return "INSERT INTO ${table} () VALUES ()"
+  }
+
+  return $self->SUPER::insert (@_);
+}
+
+1;

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/OracleJoins.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/OracleJoins.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks/OracleJoins.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -2,7 +2,7 @@
   DBIx::Class::SQLAHacks::OracleJoins;
 
 use base qw( DBIx::Class::SQLAHacks );
-use Carp::Clan qw/^DBIx::Class/;
+use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
 
 sub select {
   my ($self, $table, $fields, $where, $order, @rest) = @_;

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/SQLAHacks.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -193,6 +193,14 @@
   my $self = shift;
   my $table = shift;
   $table = $self->_quote($table) unless ref($table);
+
+  # SQLA will emit INSERT INTO $table ( ) VALUES ( )
+  # which is sadly understood only by MySQL. Change default behavior here,
+  # until SQLA2 comes with proper dialect support
+  if (! $_[0] or (ref $_[0] eq 'HASH' and !keys %{$_[0]} ) ) {
+    return "INSERT INTO ${table} DEFAULT VALUES"
+  }
+
   $self->SUPER::insert($table, @_);
 }
 

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI/mysql.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -5,7 +5,7 @@
 
 use base qw/DBIx::Class::Storage::DBI::MultiColumnIn/;
 
-# __PACKAGE__->load_components(qw/PK::Auto/);
+__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MySQL');
 
 sub with_deferred_fk_checks {
   my ($self, $sub) = @_;
@@ -53,10 +53,23 @@
 
 # MySql can not do subquery update/deletes, only way is slow per-row operations.
 # This assumes you have set proper transaction isolation and use innodb.
-sub subq_update_delete {
+sub _subq_update_delete {
   return shift->_per_row_update_delete (@_);
 }
 
+# MySql chokes on things like:
+# COUNT(*) FROM (SELECT tab1.col, tab2.col FROM tab1 JOIN tab2 ... )
+# claiming that col is a duplicate column (it loses the table specifiers by
+# the time it gets to the *). Thus for any subquery count we select only the
+# primary keys of the main table in the inner query. This hopefully still
+# hits the indexes and keeps mysql happy.
+# (mysql does not care if the SELECT and the GROUP BY match)
+sub _grouped_count_select {
+  my ($self, $source, $rs_args) = @_;
+  my @pcols = map { join '.', $rs_args->{alias}, $_ } ($source->primary_columns);
+  return @pcols ? \@pcols : $rs_args->{group_by};
+}
+
 1;
 
 =head1 NAME

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -7,7 +7,6 @@
 use warnings;
 use Carp::Clan qw/^DBIx::Class/;
 use DBI;
-use DBIx::Class::SQLAHacks;
 use DBIx::Class::Storage::DBI::Cursor;
 use DBIx::Class::Storage::Statistics;
 use Scalar::Util();
@@ -603,6 +602,7 @@
   my ($self) = @_;
   unless ($self->_sql_maker) {
     my $sql_maker_class = $self->sql_maker_class;
+    $self->ensure_class_loaded ($sql_maker_class);
     $self->_sql_maker($sql_maker_class->new( $self->_sql_maker_args ));
   }
   return $self->_sql_maker;
@@ -1104,7 +1104,7 @@
 # Genarating a single PK column subquery is trivial and supported
 # by all RDBMS. However if we have a multicolumn PK, things get ugly.
 # Look at _multipk_update_delete()
-sub subq_update_delete {
+sub _subq_update_delete {
   my $self = shift;
   my ($rs, $op, $values) = @_;
 
@@ -1197,23 +1197,17 @@
 
 sub _select_args {
   my ($self, $ident, $select, $condition, $attrs) = @_;
-  my $order = $attrs->{order_by};
 
   my $for = delete $attrs->{for};
   my $sql_maker = $self->sql_maker;
   $sql_maker->{for} = $for;
 
-  my @in_order_attrs = qw/group_by having _virtual_order_by/;
-  if (List::Util::first { exists $attrs->{$_} } (@in_order_attrs) ) {
-    $order = {
-      ($order
-        ? (order_by => $order)
-        : ()
-      ),
-      ( map { $_ => $attrs->{$_} } (@in_order_attrs) )
-    };
-  }
+  my $order = { map
+    { $attrs->{$_} ? ( $_ => $attrs->{$_} ) : ()  }
+    (qw/order_by group_by having _virtual_order_by/ )
+  };
 
+
   my $bind_attrs = {};
 
   my $alias2source = $self->_resolve_ident_sources ($ident);
@@ -1287,11 +1281,11 @@
 
   my $tmp_attrs = { %$attrs };
 
-  # take off any column specs, any pagers, record_filter is cdbi, and no point of ordering a count
-  delete $tmp_attrs->{$_} for (qw/columns +columns select +select as +as rows offset page pager order_by record_filter/);
+  # take off any pagers, record_filter is cdbi, and no point of ordering a count
+  delete $tmp_attrs->{$_} for (qw/select as rows offset page order_by record_filter/);
 
+  # overwrite the selector
   $tmp_attrs->{select} = { count => '*' };
-  $tmp_attrs->{as} = [qw/count/];
 
   my $tmp_rs = $source->resultset_class->new($source, $tmp_attrs);
   my ($count) = $tmp_rs->cursor->next;
@@ -1312,7 +1306,7 @@
   my $sub_attrs = { %$attrs };
 
   # these can not go in the subquery, and there is no point of ordering it
-  delete $sub_attrs->{$_} for qw/prefetch collapse select +select as +as columns +columns order_by/;
+  delete $sub_attrs->{$_} for qw/prefetch collapse select as order_by/;
 
   # if we prefetch, we group_by primary keys only as this is what we would get out of the rs via ->next/->all
   # simply deleting group_by suffices, as the code below will re-fill it
@@ -1321,18 +1315,30 @@
     delete $sub_attrs->{group_by};
   }
 
-  $sub_attrs->{columns} = $sub_attrs->{group_by} ||= [ map { "$attrs->{alias}.$_" } ($source->primary_columns) ];
+  $sub_attrs->{group_by} ||= [ map { "$attrs->{alias}.$_" } ($source->primary_columns) ];
+  $sub_attrs->{select} = $self->_grouped_count_select ($source, $sub_attrs);
 
   $attrs->{from} = [{
     count_subq => $source->resultset_class->new ($source, $sub_attrs )->as_query
   }];
 
   # the subquery replaces this
-  delete $attrs->{$_} for qw/where bind prefetch collapse distinct group_by having having_bind rows offset page pager/;
+  delete $attrs->{$_} for qw/where bind prefetch collapse group_by having having_bind rows offset page pager/;
 
   return $self->count ($source, $attrs);
 }
 
+#
+# Returns a SELECT to go with a supplied GROUP BY
+# (caled by count_grouped so a group_by is present)
+# Most databases expect them to match, but some
+# choke in various ways.
+#
+sub _grouped_count_select {
+  my ($self, $source, $rs_args) = @_;
+  return $rs_args->{group_by};
+}
+
 sub source_bind_attributes {
   my ($self, $source) = @_;
   

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/Statistics.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/Statistics.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/Statistics.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -89,6 +89,8 @@
 sub txn_begin {
   my $self = shift;
 
+  return if $self->callback;
+
   $self->print("BEGIN WORK\n");
 }
 
@@ -100,6 +102,8 @@
 sub txn_rollback {
   my $self = shift;
 
+  return if $self->callback;
+
   $self->print("ROLLBACK\n");
 }
 
@@ -111,6 +115,8 @@
 sub txn_commit {
   my $self = shift;
 
+  return if $self->callback;
+
   $self->print("COMMIT\n");
 }
 
@@ -122,6 +128,8 @@
 sub svp_begin {
   my ($self, $name) = @_;
 
+  return if $self->callback;
+
   $self->print("SAVEPOINT $name\n");
 }
 
@@ -133,7 +141,9 @@
 sub svp_release {
   my ($self, $name) = @_;
 
- $self->print("RELEASE SAVEPOINT $name\n");
+  return if $self->callback;
+
+  $self->print("RELEASE SAVEPOINT $name\n");
 }
 
 =head2 svp_rollback
@@ -144,7 +154,9 @@
 sub svp_rollback {
   my ($self, $name) = @_;
 
- $self->print("ROLLBACK TO SAVEPOINT $name\n");
+  return if $self->callback;
+
+  $self->print("ROLLBACK TO SAVEPOINT $name\n");
 }
 
 =head2 query_start

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/03podcoverage.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/03podcoverage.t	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/03podcoverage.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -116,6 +116,7 @@
     'DBIx::Class::Storage::DBI::Pg'                     => { skip => 1 },
     'DBIx::Class::Storage::DBI::SQLite'                 => { skip => 1 },
     'DBIx::Class::Storage::DBI::mysql'                  => { skip => 1 },
+    'DBIx::Class::SQLAHacks::MySQL'                     => { skip => 1 },
     'SQL::Translator::Parser::DBIx::Class'              => { skip => 1 },
     'SQL::Translator::Producer::DBIx::Class::File'      => { skip => 1 },
 

Added: DBIx-Class/0.08/branches/rsrc_in_storage/t/18insert_default.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/18insert_default.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/18insert_default.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $tests = 3;
+plan tests => $tests;
+
+my $schema = DBICTest->init_schema();
+my $rs = $schema->resultset ('Artist');
+my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single;
+my $last_id = $last_obj ? $last_obj->artistid : 0;
+
+my $obj;
+eval { $obj = $rs->create ({}) };
+my $err = $@;
+
+ok ($obj, 'Insert defaults ( $rs->create ({}) )' );
+SKIP: {
+  skip "Default insert failed: $err", $tests-1 if $err;
+
+  # this should be picked up without calling the DB again
+  is ($obj->artistid, $last_id + 1, 'Autoinc PK works');
+
+  # for this we need to refresh
+  $obj->discard_changes;
+  is ($obj->rank, 13, 'Default value works');
+}
+

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/52cycle.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/52cycle.t	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/52cycle.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -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/rsrc_in_storage/t/71mysql.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/71mysql.t	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/71mysql.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -14,7 +14,7 @@
 plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => 23;
+plan tests => 19;
 
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
@@ -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 }},
@@ -122,41 +122,19 @@
   );
   my $owners2 = $schema->resultset ('Owners')->search ({ id => { -in => $owners->get_column ('me.id')->as_query }});
   for ($owners, $owners2) {
-    lives_ok { is ($_->all, 2, 'Prefetched grouped search returns correct number of rows') }
-      || skip ('No test due to exception', 1);
-    lives_ok { is ($_->count, 2, 'Prefetched grouped search returns correct count') }
-      || skip ('No test due to exception', 1);
+    is ($_->all, 2, 'Prefetched grouped search returns correct number of rows');
+    is ($_->count, 2, 'Prefetched grouped search returns correct count');
   }
 
-  TODO: {
-    # try a ->prefetch direction (no select collapse)
-    my $books = $schema->resultset ('BooksInLibrary')->search (
-      { 'owner.name' => 'wiggle' },
-      { prefetch => 'owner', distinct => 1 }
-    );
-
-    local $TODO = 'MySQL is crazy - there seems to be no way to make this work';
-    # error thrown is:
-    # Duplicate column name 'id' [for Statement "
-    #   SELECT COUNT( * )
-    #     FROM (
-    #       SELECT me.id, me.source, me.owner, me.title, me.price, owner.id, owner.name
-    #         FROM books me
-    #         JOIN owners owner ON owner.id = me.owner 
-    #       WHERE ( ( owner.name = ? AND source = ? ) ) 
-    #       GROUP BY me.id, me.source, me.owner, me.title, me.price, owner.id, owner.name
-    #     ) count_subq
-    # " with ParamValues: 0='wiggle', 1='Library']
-    #
-    # go fucking figure
-
-    my $books2 = $schema->resultset ('BooksInLibrary')->search ({ id => { -in => $books->get_column ('me.id')->as_query }});
-    for ($books, $books2) {
-      lives_ok { is ($_->all, 1, 'Prefetched grouped search returns correct number of rows') }
-        || skip ('No test due to exception', 1);
-      lives_ok { is ($_->count, 1, 'Prefetched grouped search returns correct count') }
-        || skip ('No test due to exception', 1);
-    }
+  # try a ->belongs_to direction (no select collapse)
+  my $books = $schema->resultset ('BooksInLibrary')->search (
+    { 'owner.name' => 'wiggle' },
+    { prefetch => 'owner', distinct => 1 }
+  );
+  my $books2 = $schema->resultset ('BooksInLibrary')->search ({ id => { -in => $books->get_column ('me.id')->as_query }});
+  for ($books, $books2) {
+    is ($_->all, 1, 'Prefetched grouped search returns correct number of rows');
+    is ($_->count, 1, 'Prefetched grouped search returns correct count');
   }
 }
 

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/86sqlt.t	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/86sqlt.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -210,7 +210,7 @@
       'name' => 'bookmark_fk_link', 'index_name' => 'bookmark_idx_link',
       'selftable' => 'bookmark', 'foreigntable' => 'link', 
       'selfcols'  => ['link'], 'foreigncols' => ['id'],
-      on_delete => '', on_update => '', deferrable => 1,
+      on_delete => 'SET NULL', on_update => 'CASCADE', deferrable => 1,
     },
   ],
   # ForceForeign

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/AuthorCheck.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/AuthorCheck.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/AuthorCheck.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -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/rsrc_in_storage/t/lib/DBICTest/Schema/Bookmark.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Bookmark.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Bookmark.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -19,6 +19,6 @@
 );
 
 __PACKAGE__->set_primary_key('id');
-__PACKAGE__->belongs_to(link => 'DBICTest::Schema::Link' );
+__PACKAGE__->belongs_to(link => 'DBICTest::Schema::Link', 'link', { on_delete => 'SET NULL' } );
 
 1;

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Link.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Link.pm	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/lib/DBICTest/Schema/Link.pm	2009-06-09 22:48:29 UTC (rev 6577)
@@ -25,6 +25,8 @@
 );
 __PACKAGE__->set_primary_key('id');
 
+__PACKAGE__->has_many ( bookmarks => 'DBICTest::Schema::Bookmark', 'link', { cascade_delete => 0 } );
+
 use overload '""' => sub { shift->url }, fallback=> 1;
 
 1;

Copied: DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create (from rev 6521, DBIx-Class/0.08/branches/rsrc_in_storage/t/96multi_create)

Added: DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/insert_defaults.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/insert_defaults.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/insert_defaults.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+plan tests => 8;
+
+my $schema = DBICTest->init_schema();
+
+# Attempt sequential nested find_or_create with autoinc
+# As a side effect re-test nested default create (both the main object and the relation are {})
+my $bookmark_rs = $schema->resultset('Bookmark');
+my $last_bookmark = $bookmark_rs->search ({}, { order_by => { -desc => 'id' }, rows => 1})->single;
+my $last_link = $bookmark_rs->search_related ('link', {}, { order_by => { -desc => 'link.id' }, rows => 1})->single;
+
+# find_or_create a bookmark-link combo with data for a non-existing link
+my $o1 = $bookmark_rs->find_or_create ({ link => { url => 'something-weird' } });
+is ($o1->id, $last_bookmark->id + 1, '1st bookmark ID');
+is ($o1->link->id, $last_link->id + 1, '1st related link ID');
+
+# find_or_create a bookmark-link combo without any data at all (default insert)
+# should extend this test to all available Storage's, and fix them accordingly
+my $o2 = $bookmark_rs->find_or_create ({ link => {} });
+is ($o2->id, $last_bookmark->id + 2, '2nd bookmark ID');
+is ($o2->link->id, $last_link->id + 2, '2nd related link ID');
+
+# make sure the pre-existing link has only one related bookmark
+is ($last_link->bookmarks->count, 1, 'Expecting only 1 bookmark and 1 link, someone mucked with the table!');
+
+# find_or_create a bookmark withouyt any data, but supplying an existing link object
+# should return $last_bookmark
+my $o0 = $bookmark_rs->find_or_create ({ link => $last_link });
+is_deeply ({ $o0->columns}, {$last_bookmark->columns}, 'Correctly identify a row given a relationship');
+
+# inject an additional bookmark and repeat the test
+# should warn and return the first row
+my $o3 = $last_link->create_related ('bookmarks', {});
+is ($o3->id, $last_bookmark->id + 3, '3rd bookmark ID');
+
+local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /Query returned more than one row/ };
+my $oX = $bookmark_rs->find_or_create ({ link => $last_link });
+is_deeply ({ $oX->columns}, {$last_bookmark->columns}, 'Correctly identify a row given a relationship');

Added: DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/m2m.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/m2m.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/m2m.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+plan tests => 4;
+
+my $schema = DBICTest->init_schema();
+
+lives_ok ( sub {
+
+  my $prod_rs = $schema->resultset ('Producer');
+  my $prod_count = $prod_rs->count;
+
+  my $cd = $schema->resultset('CD')->first;
+  $cd->add_to_producers ({name => 'new m2m producer'});
+
+  is ($prod_rs->count, $prod_count + 1, 'New producer created');
+  ok ($cd->producers->find ({name => 'new m2m producer'}), 'Producer created with correct name');
+
+  my $cd2 = $schema->resultset('CD')->search ( { cdid => { '!=', $cd->cdid } }, {rows => 1} )->single;  # retrieve a cd different from the first
+  $cd2->add_to_producers ({name => 'new m2m producer'});                                                # attach to an existing producer
+  ok ($cd2->producers->find ({name => 'new m2m producer'}), 'Exsiting producer attached to existing cd');
+
+}, 'Test far-end find_or_create over many_to_many');
+
+1;

Added: DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/reentrance_count.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/reentrance_count.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/multi_create/reentrance_count.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -0,0 +1,180 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+plan 'no_plan';
+
+my $schema = DBICTest->init_schema();
+
+my $query_stats;
+$schema->storage->debugcb (sub { push @{$query_stats->{$_[0]}}, $_[1] });
+$schema->storage->debug (1);
+
+TODO: {
+  local $TODO = 'This is an optimization task, will wait... a while';
+
+lives_ok (sub {
+  undef $query_stats;
+  $schema->resultset('Artist')->create ({
+    name => 'poor artist',
+    cds => [
+      {
+        title => 'cd1',
+        year => 2001,
+      },
+      {
+        title => 'cd2',
+        year => 2002,
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+
+lives_ok (sub {
+  undef $query_stats;
+  $schema->resultset('Artist')->create ({
+    name => 'poorer artist',
+    cds => [
+      {
+        title => 'cd3',
+        year => 2003,
+        genre => { name => 'vague genre' },
+      },
+      {
+        title => 'cd4',
+        year => 2004,
+        genre => { name => 'vague genre' },
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of artist with 2 cds, converging on the same genre' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same genre' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+
+lives_ok (sub {
+  my $genre = $schema->resultset('Genre')->first;
+  undef $query_stats;
+  $schema->resultset('Artist')->create ({
+    name => 'poorest artist',
+    cds => [
+      {
+        title => 'cd5',
+        year => 2005,
+        genre => $genre,
+      },
+      {
+        title => 'cd6',
+        year => 2004,
+        genre => $genre,
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds, converging on the same existing genre' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same existing genre' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+
+lives_ok (sub {
+  undef $query_stats;
+  $schema->resultset('Artist')->create ({
+    name => 'poorer than the poorest artist',
+    cds => [
+      {
+        title => 'cd7',
+        year => 2007,
+        cd_to_producer => [
+          {
+            producer => {
+              name => 'jolly producer',
+              producer_to_cd => [
+                {
+                  cd => {
+                    title => 'cd8',
+                    year => 2008,
+                    artist => {
+                      name => 'poorer than the poorest artist',
+                    },
+                  },
+                },
+              ],
+            },
+          },
+        ],
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 6, 'number of inserts during creation of artist->cd->producer->cd->same_artist' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist->cd->producer->cd->same_artist' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+lives_ok (sub {
+  undef $query_stats;
+  $schema->resultset ('Artist')->find(1)->create_related (cds => {
+    title => 'cd9',
+    year => 2009,
+    cd_to_producer => [
+      {
+        producer => {
+          name => 'jolly producer',
+          producer_to_cd => [
+            {
+              cd => {
+                title => 'cd10',
+                year => 2010,
+                artist => {
+                  name => 'poorer than the poorest artist',
+                },
+              },
+            },
+          ],
+        },
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of existing_artist->cd->existing_producer->cd->existing_artist2' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of existing_artist->cd->existing_producer->cd->existing_artist2' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+lives_ok (sub {
+  undef $query_stats;
+
+  my $artist = $schema->resultset ('Artist')->first;
+  my $producer = $schema->resultset ('Producer')->first;
+
+  $schema->resultset ('CD')->create ({
+    title => 'cd11',
+    year => 2011,
+    artist => $artist,
+    cd_to_producer => [
+      {
+        producer => $producer,
+      },
+    ],
+  });
+
+  is ( @{$query_stats->{INSERT} || []}, 2, 'number of inserts during creation of artist_object->cd->producer_object' );
+  is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist_object->cd->producer_object' )
+    || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
+});
+
+}
+
+1;

Modified: DBIx-Class/0.08/branches/rsrc_in_storage/t/prefetch/rows_bug.t
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/t/prefetch/rows_bug.t	2009-06-09 22:48:07 UTC (rev 6576)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/t/prefetch/rows_bug.t	2009-06-09 22:48:29 UTC (rev 6577)
@@ -7,7 +7,7 @@
 use lib qw(t/lib);
 use DBICTest;
 
-plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 2);
+plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 3);
 
 my $schema = DBICTest->init_schema();
 my $no_prefetch = $schema->resultset('Artist')->search(
@@ -28,19 +28,38 @@
 
 is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
 
-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)"
-  );
-}
+$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)"
+);
 
+$no_prefetch = $schema->resultset('Artist')->search(
+  undef,
+  { rows => 1 }
+);
+
+$use_prefetch = $schema->resultset('Artist')->search(
+  undef,
+  {
+    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"
+);
+
 __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
@@ -78,6 +97,7 @@
 Problem:
   * The prefetch->join change needs to happen ONLY IF there are conditions
     that depend on bar being joined.
+  * Count of child rel.
   * 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.




More information about the Bast-commits mailing list