[Bast-commits] r3283 - in
branches/DBIx-Class/collapse_result_rewrite: . lib/DBIx
lib/DBIx/Class lib/DBIx/Class/CDBICompat
lib/DBIx/Class/InflateColumn lib/DBIx/Class/Manual
lib/DBIx/Class/Relationship lib/DBIx/Class/Storage
lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/Oracle
lib/SQL/Translator/Parser/DBIx t t/cdbi-t t/lib/DBICTest
t/lib/DBICTest/Schema t/testlib
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Thu May 10 22:30:41 GMT 2007
Author: matthewt
Date: 2007-05-10 22:30:41 +0100 (Thu, 10 May 2007)
New Revision: 3283
Added:
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/File.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Joining.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/WhereJoins.pm
branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/ExplodingStorage.pm
branches/DBIx-Class/collapse_result_rewrite/t/resultset_class.t
branches/DBIx-Class/collapse_result_rewrite/t/testlib/OtherThing.pm
branches/DBIx-Class/collapse_result_rewrite/t/testlib/Thing.pm
Removed:
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/FileColumn.pm
Modified:
branches/DBIx-Class/collapse_result_rewrite/
branches/DBIx-Class/collapse_result_rewrite/Changes
branches/DBIx-Class/collapse_result_rewrite/MANIFEST.SKIP
branches/DBIx-Class/collapse_result_rewrite/Makefile.PL
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/CDBICompat/HasMany.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Componentised.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Cursor.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/DateTime.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Cookbook.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/FAQ.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Intro.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Troubleshooting.pod
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Ordered.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship/Base.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSet.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSource.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Row.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Schema.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Cursor.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Pg.pm
branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/SQLite.pm
branches/DBIx-Class/collapse_result_rewrite/lib/SQL/Translator/Parser/DBIx/Class.pm
branches/DBIx-Class/collapse_result_rewrite/t/76joins.t
branches/DBIx-Class/collapse_result_rewrite/t/92storage.t
branches/DBIx-Class/collapse_result_rewrite/t/94versioning.t
branches/DBIx-Class/collapse_result_rewrite/t/96file_column.t
branches/DBIx-Class/collapse_result_rewrite/t/bindtype_columns.t
branches/DBIx-Class/collapse_result_rewrite/t/cdbi-t/09-has_many.t
branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/Schema/FileColumn.pm
Log:
r35890 at cain (orig r3047): victori | 2007-01-21 00:48:49 +0000
changed FileColumn to InflateColumn::File
r35914 at cain (orig r3056): jnapiorkowski | 2007-01-24 17:58:59 +0000
-- Fixed tabs to spaces issue
-- got rid of deprecation warning
-- removed default postgres credentials, now if you don't have the PG testing env exported than the tests are skipped.
-- tests properly pass now.
r35958 at cain (orig r3060): castaway | 2007-01-25 20:03:16 +0000
0.07999_02, add skip on prefetch test
r35988 at cain (orig r3068): castaway | 2007-01-31 14:06:49 +0000
Oops, cross-platform filename checking!
r35989 at cain (orig r3069): castaway | 2007-01-31 14:10:24 +0000
Ahem, now passes -c too
r35991 at cain (orig r3071): victori | 2007-02-01 00:36:29 +0000
whoopes forgot to change the package name for dbix::class::inflatecolumn::file
r36100 at cain (orig r3108): djo | 2007-03-03 17:58:21 +0000
r27233 at ip-37-237 (orig r3005): castaway | 2007-01-05 10:25:11 +0100
add inflatecolumn fixes to Changes
r27496 at ip-37-237 (orig r3007): castaway | 2007-01-09 22:20:55 +0100
todoify collapse test
r27497 at ip-37-237 (orig r3008): castaway | 2007-01-09 22:42:59 +0100
Up version to 0.07004
r27498 at ip-37-237 (orig r3009): castaway | 2007-01-09 22:44:39 +0100
0.07004
r27499 at ip-37-237 (orig r3010): castaway | 2007-01-10 18:54:19 +0100
Skip .orig files in dist
r27500 at ip-37-237 (orig r3011): castaway | 2007-01-10 20:37:23 +0100
oops, remove .orig files etc
r27546 at ip-37-237 (orig r3053): zarquon | 2007-01-23 11:15:05 +0100
minor doc improvement to clarify how to do joins
r27720 at ip-37-237 (orig r3058): zarquon | 2007-01-24 22:48:07 +0100
explained a cryptic error message
r27732 at ip-37-237 (orig r3064): castaway | 2007-01-29 17:28:12 +0100
Make POD a little more obvious about component order
--This line, and those below, will be ignored--
M DateTime.pm
r27738 at ip-37-237 (orig r3070): jester | 2007-02-01 00:59:06 +0100
Doc cleanup in Ordered.pm
r27740 at ip-37-237 (orig r3072): castaway | 2007-02-02 20:48:53 +0100
POD updates
r27741 at ip-37-237 (orig r3073): ash | 2007-02-03 22:33:19 +0100
Made ->update not change the hashref passed in (with test.)
r27743 at ip-37-237 (orig r3075): ash | 2007-02-05 13:29:52 +0100
Backed out my r3073, and doc'd the fact that it takes a hashref that might be changed
r27744 at ip-37-237 (orig r3076): castaway | 2007-02-05 14:56:35 +0100
Add _accessor example, thanks to grinktt3n
r27745 at ip-37-237 (orig r3077): castaway | 2007-02-05 15:23:22 +0100
Fix overload example
r27747 at ip-37-237 (orig r3079): grink1tt3n | 2007-02-06 20:40:00 +0100
Added;
FAQ-fetch-a-formatted-column.txt
FAQ-store-JSON-in-a-column.txt
r27762 at ip-37-237 (orig r3094): castaway | 2007-02-08 09:25:54 +0100
Argh! Fix spurious example
r27765 at ip-37-237 (orig r3097): castaway | 2007-02-13 15:00:21 +0100
Improve resultset_attributes docs
r27766 at ip-37-237 (orig r3098): grink1tt3n | 2007-02-14 08:16:40 +0100
Fleshed out the JSON inflated column example with a corresponding YAML example. Added a cautionary warning against overuse. Added a link to InflateColumn.
r27767 at ip-37-237 (orig r3099): grink1tt3n | 2007-02-14 09:39:26 +0100
Added how to '.. fetch a single (or topmost) row?' to the FAQ
r27768 at ip-37-237 (orig r3100): zarquon | 2007-02-14 09:44:18 +0100
improved docs for as attrib
r27769 at ip-37-237 (orig r3101): zarquon | 2007-02-14 11:05:51 +0100
pointed out ambiguity of as attribs
r27967 at ip-37-237 (orig r3107): castaway | 2007-03-03 13:15:03 +0100
Fix to $filename from Carl Vincent
r36101 at cain (orig r3109): djo | 2007-03-03 20:12:44 +0000
Reverted accidental 'svk pull' from inside mirrored checkout.
Note to self: Don't checkout anything from //mirror - Even if you have no need to edit it...
r36111 at cain (orig r3119): ash | 2007-03-07 17:28:08 +0000
We need JSON > 1.00 for dbicadmin
r36114 at cain (orig r3122): djo | 2007-03-09 22:02:40 +0000
Disabled broken inflate/deflate.
Current now passes all tests again.
(DBIx::Class::InflateColumn::File is still broken)
r36126 at cain (orig r3131): ash | 2007-03-17 19:25:17 +0000
fix server disconnect checking for select outside of transaction
r36128 at cain (orig r3133): ash | 2007-03-18 23:58:07 +0000
sqlt parser now respected a relationship attribute of is_foreign_key_constraint
r41927 at cain (orig r3203): dduncan | 2007-04-22 03:34:04 +0000
branches/DBIx-Class-current/ : trivial test first commit ; removed trailing whitespace in Changes (7 lines)
r41989 at cain (orig r3212): dnm | 2007-04-26 16:09:29 +0000
Made Oracle/WhereJoins for using in Oracle 8 and higher because Oracle < 9i
doesn't support ANSI joins, and Oracle >= 9i doesn't do ANSI joins worth a
damn.
r41990 at cain (orig r3213): dnm | 2007-04-26 16:43:17 +0000
Removed 8.pm and updated Changelog.
r41991 at cain (orig r3214): dnm | 2007-04-26 17:58:16 +0000
I'm a retard.
r50483 at cain (orig r3221): blblack | 2007-05-01 05:41:32 +0000
r20551 at brandon-blacks-computer (orig r3005): castaway | 2007-01-05 03:25:11 -0600
add inflatecolumn fixes to Changes
r20553 at brandon-blacks-computer (orig r3007): castaway | 2007-01-09 15:20:55 -0600
todoify collapse test
r20554 at brandon-blacks-computer (orig r3008): castaway | 2007-01-09 15:42:59 -0600
Up version to 0.07004
r20555 at brandon-blacks-computer (orig r3009): castaway | 2007-01-09 15:44:39 -0600
0.07004
r20556 at brandon-blacks-computer (orig r3010): castaway | 2007-01-10 11:54:19 -0600
Skip .orig files in dist
r20557 at brandon-blacks-computer (orig r3011): castaway | 2007-01-10 13:37:23 -0600
oops, remove .orig files etc
r20599 at brandon-blacks-computer (orig r3053): zarquon | 2007-01-23 04:15:05 -0600
minor doc improvement to clarify how to do joins
r20604 at brandon-blacks-computer (orig r3058): zarquon | 2007-01-24 15:48:07 -0600
explained a cryptic error message
r20610 at brandon-blacks-computer (orig r3064): castaway | 2007-01-29 10:28:12 -0600
Make POD a little more obvious about component order
--This line, and those below, will be ignored--
M DateTime.pm
r20616 at brandon-blacks-computer (orig r3070): jester | 2007-01-31 17:59:06 -0600
Doc cleanup in Ordered.pm
r20618 at brandon-blacks-computer (orig r3072): castaway | 2007-02-02 13:48:53 -0600
POD updates
r20619 at brandon-blacks-computer (orig r3073): ash | 2007-02-03 15:33:19 -0600
Made ->update not change the hashref passed in (with test.)
r20621 at brandon-blacks-computer (orig r3075): ash | 2007-02-05 06:29:52 -0600
Backed out my r3073, and doc'd the fact that it takes a hashref that might be changed
r20622 at brandon-blacks-computer (orig r3076): castaway | 2007-02-05 07:56:35 -0600
Add _accessor example, thanks to grinktt3n
r20623 at brandon-blacks-computer (orig r3077): castaway | 2007-02-05 08:23:22 -0600
Fix overload example
r20625 at brandon-blacks-computer (orig r3079): grink1tt3n | 2007-02-06 13:40:00 -0600
Added;
FAQ-fetch-a-formatted-column.txt
FAQ-store-JSON-in-a-column.txt
r20640 at brandon-blacks-computer (orig r3094): castaway | 2007-02-08 02:25:54 -0600
Argh! Fix spurious example
r20643 at brandon-blacks-computer (orig r3097): castaway | 2007-02-13 08:00:21 -0600
Improve resultset_attributes docs
r20644 at brandon-blacks-computer (orig r3098): grink1tt3n | 2007-02-14 01:16:40 -0600
Fleshed out the JSON inflated column example with a corresponding YAML example. Added a cautionary warning against overuse. Added a link to InflateColumn.
r20645 at brandon-blacks-computer (orig r3099): grink1tt3n | 2007-02-14 02:39:26 -0600
Added how to '.. fetch a single (or topmost) row?' to the FAQ
r20646 at brandon-blacks-computer (orig r3100): zarquon | 2007-02-14 02:44:18 -0600
improved docs for as attrib
r20647 at brandon-blacks-computer (orig r3101): zarquon | 2007-02-14 04:05:51 -0600
pointed out ambiguity of as attribs
r26909 at brandon-blacks-computer (orig r3107): castaway | 2007-03-03 06:15:03 -0600
Fix to $filename from Carl Vincent
r27114 at brandon-blacks-computer (orig r3126): jshirley | 2007-03-12 16:27:08 -0500
Updating Manual/Intro to reflect better -in => [] usage, adding myself to contributors (mst put me in dbic-devel, too)
r27116 at brandon-blacks-computer (orig r3128): castaway | 2007-03-14 10:02:44 -0500
Added patch from Schwern to allow cdbi compat to infer the has_many from a has_a
r27119 at brandon-blacks-computer (orig r3129): castaway | 2007-03-16 11:04:07 -0500
Initial version of Manual::Joining
r27120 at brandon-blacks-computer (orig r3130): castaway | 2007-03-16 11:06:21 -0500
Add FAQ and Joining links to Manual.pod
r27319 at brandon-blacks-computer (orig r3148): blblack | 2007-03-29 08:42:27 -0500
fix for rt.cpan.org #25683 (DBD::Sybase/FreeTDS/MSSQL cannot have two open sths during column_info
r27324 at brandon-blacks-computer (orig r3153): blblack | 2007-03-29 09:13:17 -0500
backport Ash's quoting fix from Loader to columns_info_for
r29666 at brandon-blacks-computer (orig r3173): castaway | 2007-04-02 17:19:05 -0500
Add patch from dec to allow us to pick which sources to deploy
r30330 at brandon-blacks-computer (orig r3185): matthewt | 2007-04-09 15:41:34 -0500
add SQL::Abstract to search docs (patch from zamolxes)
r30510 at brandon-blacks-computer (orig r3189): blblack | 2007-04-13 19:09:32 -0500
fixed regex in t/76joins (was relying on a 5.8.8 bug that is fixed in bleadperl, so this test was failing on bleadperl)
r30560 at brandon-blacks-computer (orig r3196): marcus | 2007-04-16 07:55:44 -0500
Updated cookbook example
r30589 at brandon-blacks-computer (orig r3199): blblack | 2007-04-17 18:45:11 -0500
Changes list synced up through now
r30590 at brandon-blacks-computer (orig r3200): blblack | 2007-04-17 18:47:03 -0500
cleared up a Changes entry
r30591 at brandon-blacks-computer (orig r3201): blblack | 2007-04-17 19:21:01 -0500
0.07006 changes, version update
r30607 at brandon-blacks-computer (orig r3202): matthewt | 2007-04-18 21:29:05 -0500
reverting r3173, already implemented in -current
r30709 at brandon-blacks-computer (orig r3208): matthewt | 2007-04-24 17:04:02 -0500
oops. props to chapman for the spot
r30762 at brandon-blacks-computer (orig r3220): blblack | 2007-05-01 00:25:33 -0500
load-time performance improvements
r50488 at cain (orig r3226): blblack | 2007-05-03 03:03:06 +0000
r30777 at brandon-blacks-computer (orig r3224): nigel | 2007-05-02 09:58:45 -0500
Documented use of cursor->next for fast but uncomfortable data fetches
r30778 at brandon-blacks-computer (orig r3225): blblack | 2007-05-02 22:02:14 -0500
revert part of 3220, apparently it is breaking cloning behavior in subtle ways that we have no tests for
r50735 at cain (orig r3265): ash | 2007-05-08 19:35:36 +0000
Unbreak back-compat
r50736 at cain (orig r3266): ash | 2007-05-08 19:41:38 +0000
Move -result_source handling further up
r50744 at cain (orig r3274): castaway | 2007-05-09 22:42:11 +0000
No nested transactions in SQLite.
r50745 at cain (orig r3275): claco | 2007-05-10 00:18:35 +0000
resultset_class/result_class now (again) auto loads the specified class; requires Class::Accessor::Grouped 0.05000+
r50749 at cain (orig r3279): blblack | 2007-05-10 21:11:04 +0000
do not try to silently handle disconnects when in a manual txn_begin/txn_end transaction
r50750 at cain (orig r3280): blblack | 2007-05-10 21:13:14 +0000
docs about side-effects in txn_do coderef
Property changes on: branches/DBIx-Class/collapse_result_rewrite
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
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/column_info_from_storage:2596
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/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
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/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:2994
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.current:29201
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.oracle8:29250
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:3280
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/column_info_from_storage:2596
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/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
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/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3225
Modified: branches/DBIx-Class/collapse_result_rewrite/Changes
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/Changes 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/Changes 2007-05-10 21:30:41 UTC (rev 3283)
@@ -1,5 +1,25 @@
Revision history for DBIx::Class
+ - Added Oracle/WhereJoins.pm for Oracle >= 8 to support
+ Oracle <= 9i, and provide Oracle with a better join method for
+ later versions. (I use the term better loosely.)
+ - select et al weren't properly detecing when the server connection
+ had timed out when not in a transaction
+ - The SQL::T parser class now respects a relationship attribute of
+ is_foreign_key_constrain to allow explicit control over wether or
+ not a foreign constraint is needed
+ - resultset_class/result_class now (again) auto loads the specified
+ class; requires Class::Accessor::Grouped 0.05000+
+
+0.07006 2007-04-17 23:18:00
+ - Lots of documentation updates
+ - deploy now takes an optional 'source_names' parameter (dec)
+ - Quoting for for columns_info_for
+ - RT#25683 fixed (multiple open sths on DBD::Sybase)
+ - CDBI compat infers has_many from has_a (Schwern)
+ - Fix ddl_filename transformation (Carl Vincent)
+
+0.07999_02 2007-01-25 20:11:00
- add support for binding BYTEA and similar parameters (w/Pg impl)
- add support to Ordered for multiple ordering columns
- mark DB.pm and compose_connection as deprecated
@@ -8,6 +28,24 @@
- Changed row and rs objects to not have direct handle to a source,
instead a (schema,source_name) tuple of type ResultSourceHandle
+0.07005 2007-01-10 18:36:00
+ - fixup changes file
+ - remove erroneous .orig files - oops
+
+0.07004 2007-01-09 21:52:00
+ - fix find_related-based queries to correctly grep the unique key
+ - fix InflateColumn to inflate/deflate all refs but scalar refs
+
+0.07003 2006-11-16 11:52:00
+ - fix for rt.cpan.org #22740 (use $^X instead of hardcoded "perl")
+ - Tweaks to resultset to allow inflate_result to return an array
+ - Fix UTF8Columns to work under Perl <= 5.8.0
+ - Fix up new_result in ResultSet to avoid alias-related bugs
+ - Made new/update/find handle 'single' rel accessor correctly
+ - Fix NoBindVars to be safer and handle non-true bind values
+ - Don't blow up if columns_info_for returns useless results
+ - Documentation updates
+
0.07999_01 2006-10-05 21:00:00
- add connect_info option "disable_statement_caching"
- create insert_bulk using execute_array, populate uses it
@@ -25,25 +63,12 @@
You can make it work like before via
__PACKAGE__->column_info_from_storage(1) for now
- Replaced DBIx::Class::AccessorGroup and Class::Data::Accessor with
- Class::Accessor::Grouped. Only user noticible change is to
- table_class on ResultSourceProxy::Table (i.e. table objects in
- schemas) and, resultset_class and result_class in ResultSource.
+ Class::Accessor::Grouped. Only user noticible change is to
+ table_class on ResultSourceProxy::Table (i.e. table objects in
+ schemas) and, resultset_class and result_class in ResultSource.
These accessors no longer automatically require the classes when
set.
-0.07004
- - fix find_related-based queries to correctly grep the unique key
-
-0.07003 2006-11-16 11:52:00
- - fix for rt.cpan.org #22740 (use $^X instead of hardcoded "perl")
- - Tweaks to resultset to allow inflate_result to return an array
- - Fix UTF8Columns to work under Perl <= 5.8.0
- - Fix up new_result in ResultSet to avoid alias-related bugs
- - Made new/update/find handle 'single' rel accessor correctly
- - Fix NoBindVars to be safer and handle non-true bind values
- - Don't blow up if columns_info_for returns useless results
- - Documentation updates
-
0.07002 2006-09-14 21:17:32
- fix quote tests for recent versions of SQLite
- added reference implementation of Manual::Example
@@ -114,7 +139,7 @@
- fixes to pass test suite on Windows
- rewrote and cleaned up SQL::Translator tests
- changed relationship helpers to only call ensure_class_loaded when the
- join condition is inferred
+ join condition is inferred
- rewrote many_to_many implementation, now provides helpers for adding
and deleting objects without dealing with the link table
- reworked InflateColumn implementation to lazily deflate where
@@ -122,12 +147,12 @@
- changed join merging to not create a rel_2 alias when adding a join
that already exists in a parent resultset
- Storage::DBI::deployment_statements now calls ensure_connected
- if it isn't passed a type
+ if it isn't passed a type
- fixed Componentized::ensure_class_loaded
- InflateColumn::DateTime supports date as well as datetime
- split Storage::DBI::MSSQL into MSSQL and Sybase::MSSQL
- - fixed wrong debugging hook call in Storage::DBI
- - set connect_info properly before setting any ->sql_maker things
+ - fixed wrong debugging hook call in Storage::DBI
+ - set connect_info properly before setting any ->sql_maker things
0.06999_02 2006-06-09 23:58:33
- Fixed up POD::Coverage tests, filled in some POD holes
@@ -285,7 +310,8 @@
0.05002 2006-02-06 12:12:03
- Added recommends for Class::Inspector
- - Added skip_all to t/40resultsetmanager.t if no Class::Inspector available
+ - Added skip_all to t/40resultsetmanager.t if no Class::Inspector
+ available
0.05001 2006-02-05 15:28:10
- debug output now prints NULL for undef params
@@ -325,8 +351,10 @@
0.04999_04 2006-01-24 21:48:21
- more documentation improvements
- - add columns_info_for for vendor-specific column info (Zbigniew Lukasiak)
- - add SQL::Translator::Producer for DBIx::Class table classes (Jess Robinson)
+ - add columns_info_for for vendor-specific column info (Zbigniew
+ Lukasiak)
+ - add SQL::Translator::Producer for DBIx::Class table classes (Jess
+ Robinson)
- add unique constraint declaration (Daniel Westermann-Clark)
- add new update_or_create method (Daniel Westermann-Clark)
- rename ResultSetInstance class to ResultSetProxy, ResultSourceInstance
@@ -336,11 +364,13 @@
0.04999_03 2006-01-20 06:05:27
- imported Jess Robinson's SQL::Translator::Parser::DBIx::Class
- - lots of internals cleanup to eliminate result_source_instance requirement
+ - lots of internals cleanup to eliminate result_source_instance
+ requirement
- added register_column and register_relationship class APIs
- made Storage::DBI use prepare_cached safely (thanks to Tim Bunce)
- many documentation improvements (thanks guys!)
- - added ->connection, ->connect, ->register_source and ->clone schema methods
+ - added ->connection, ->connect, ->register_source and ->clone schema
+ methods
- Use croak instead of die for user errors.
0.04999_02 2006-01-14 07:17:35
@@ -413,3 +443,4 @@
0.01 2005-08-08 17:10:00
- initial release
+
Modified: branches/DBIx-Class/collapse_result_rewrite/MANIFEST.SKIP
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/MANIFEST.SKIP 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/MANIFEST.SKIP 2007-05-10 21:30:41 UTC (rev 3283)
@@ -41,5 +41,8 @@
# Skip maint stuff
^maint/
+# Avoid copies to .orig
+\.orig$
+
# Dont use Module::Build anymore
# Build.PL
Modified: branches/DBIx-Class/collapse_result_rewrite/Makefile.PL
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/Makefile.PL 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/Makefile.PL 2007-05-10 21:30:41 UTC (rev 3283)
@@ -15,7 +15,8 @@
requires 'DBI' => 1.40;
requires 'Module::Find' => 0;
requires 'Class::Inspector' => 0;
-requires 'Class::Accessor::Grouped' => 0.03;
+requires 'Class::Accessor::Grouped' => 0.05000;
+requires 'JSON' => 1.00;
# Perl 5.8.0 doesn't have utf8::is_utf8()
requires 'Encode' => 0 if ($] <= 5.008000);
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/CDBICompat/HasMany.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/CDBICompat/HasMany.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/CDBICompat/HasMany.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -20,6 +20,12 @@
$args->{cascade_delete} = 0;
}
+ if( !$f_key and !@f_method ) {
+ my $f_source = $f_class->result_source_instance;
+ ($f_key) = grep { $f_source->relationship_info($_)->{class} eq $class }
+ $f_source->relationships;
+ }
+
$class->next::method($rel, $f_class, $f_key, $args);
if (@f_method) {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Componentised.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Componentised.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Componentised.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -33,8 +33,7 @@
# it on the basis of the comments in Class::C3, the author was on #dbix-class
# while I was implementing this.
- my $table = { Class::C3::_dump_MRO_table };
- eval "package $target; import Class::C3;" unless exists $table->{$target};
+ eval "package $target; import Class::C3;" unless exists $Class::C3::MRO{$target};
}
sub load_components {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Cursor.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Cursor.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Cursor.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -38,7 +38,8 @@
=head2 next
-Virtual method. Advances the cursor to the next row.
+Virtual method. Advances the cursor to the next row. Returns an array of
+column values (the result of L<DBI/fetchrow_array> method).
=cut
Deleted: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/FileColumn.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/FileColumn.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/FileColumn.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -1,208 +0,0 @@
-package DBIx::Class::FileColumn;
-
-use strict;
-use warnings;
-use base 'DBIx::Class';
-use File::Path;
-use File::Copy;
-use IO::File;
-
-sub inflate_result {
- my $self = shift;
- my $ret = $self->next::method(@_);
-
- $self->_inflate_file_column($ret);
- return $ret;
-}
-
-sub insert {
- my ( $self, @rest ) = @_;
-
- my ( $file, @column_names ) = $self->_load_file_column_information;
- my $ret = $self->next::method(@rest);
- $self->_save_file_column( $file, $ret, @column_names );
- return $ret;
-}
-
-sub update {
- my ($self, @rest ) = @_;
-
- my ( $file, @column_names ) = $self->_load_file_column_information;
- my $ret = $self->next::method(@rest);
- $self->_save_file_column( $file, $ret, @column_names );
- return $ret;
-}
-
-sub delete {
- my ( $self, @rest ) = @_;
-
- my @column_names = $self->columns;
- for (@column_names) {
- if ( $self->column_info($_)->{is_file_column} ) {
- my $path =
- File::Spec->catdir( $self->column_info($_)->{file_column_path},
- $self->id );
- rmtree( [$path], 0, 0 );
- }
- }
-
- my $ret = $self->next::method(@rest);
-
- return $ret;
-}
-
-sub _inflate_file_column {
- my $self = shift;
- my $ret = shift;
-
- my @column_names = $self->columns;
- for(@column_names) {
- if ( $ret->column_info($_)->{is_file_column} ) {
- # make sure everything checks out
- unless (defined $ret->$_) {
- # if something is wrong set it to undef
- $ret->$_(undef);
- next;
- }
- my $fs_file =
- File::Spec->catfile( $ret->column_info($_)->{file_column_path},
- $ret->id, $ret->$_ );
- $ret->$_({handle => new IO::File($fs_file, "r"), filename => $ret->$_});
- }
- }
-}
-
-sub _load_file_column_information {
- my $self = shift;
-
- my $file;
- my @column_names;
-
- @column_names = $self->columns;
- for (@column_names) {
- if ( $self->column_info($_)->{is_file_column} ) {
- # make sure everything checks out
- unless ((defined $self->$_) ||
- (defined $self->$_->{filename} && defined $self->$_->{handle})) {
- # if something is wrong set it to undef
- $self->$_(undef);
- next;
- }
- $file->{$_} = $self->$_;
- $self->$_( $self->$_->{filename} );
- }
- }
-
- return ( $file, @column_names );
-}
-
-sub _save_file_column {
- my ( $self, $file, $ret, @column_names ) = @_;
-
- for (@column_names) {
- if ( $ret->column_info($_)->{is_file_column} ) {
- next unless (defined $ret->$_);
- my $file_path =
- File::Spec->catdir( $ret->column_info($_)->{file_column_path},
- $ret->id );
- mkpath [$file_path];
-
- my $outfile =
- File::Spec->catfile( $file_path, $file->{$_}->{filename} );
- File::Copy::copy( $file->{$_}->{handle}, $outfile );
-
- $self->_file_column_callback($file->{$_},$ret,$_);
- }
- }
-}
-
-=head1 METHODS
-
-=cut
-
-
-=head2 _file_column_callback ($file,$ret,$target)
-
-method made to be overridden for callback purposes.
-
-=cut
-
-sub _file_column_callback {
- my ($self,$file,$ret,$target) = @_;
-}
-
-=head1 NAME
-
-DBIx::Class::FileColumn - FileColumn map files from the Database to the filesystem.
-
-=head1 DESCRIPTION
-
-FileColumn
-
-=head1 SYNOPSIS
-
-In your L<DBIx::Class> table class:
-
- __PACKAGE__->load_components( "PK::Auto", "FileColumn", "Core" );
-
- # define your columns
- __PACKAGE__->add_columns(
- "id",
- {
- data_type => "integer",
- is_auto_increment => 1,
- is_nullable => 0,
- size => 4,
- },
- "filename",
- {
- data_type => "varchar",
- is_file_column => 1,
- file_column_path =>'/tmp/uploaded_files',
- # or for a Catalyst application
- # file_column_path => MyApp->path_to('root','static','files'),
- default_value => undef,
- is_nullable => 1,
- size => 255,
- },
- );
-
-
-In your L<Catalyst::Controller> class:
-
-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({
- subject => 'blah',
- filename => {
- handle => $c->req->upload('myupload')->fh,
- filename => $c->req->upload('myupload')->basename
- },
- body => '....'
- });
- $c->stash->{entry}=$entry;
-
-
-And Place the following in your TT template
-
- Article Subject: [% entry.subject %]
- Uploaded File:
- <a href="/static/files/[% entry.id %]/[% entry.filename.filename %]">File</a>
- Body: [% entry.body %]
-
-The file will be stored on the filesystem for later retrieval.
-Calling delete on your resultset will delete the file from the filesystem.
-Retrevial of the record automatically inflates the column back to the set hash with the IO::File handle and filename.
-
-=head1 AUTHOR
-
-Victor Igumnov
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/DateTime.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/DateTime.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -14,7 +14,7 @@
columns to be of the datetime, timestamp or date datatype.
package Event;
- __PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+ __PACKAGE__->load_components(qw/Core InflateColumn::DateTime/);
__PACKAGE__->add_columns(
starts_when => { data_type => 'datetime' }
);
@@ -33,7 +33,7 @@
that this feature is new as of 0.07, so it may not be perfect yet - bug
reports to the list very much welcome).
-For more help with components, see L<DBIx::Class::Manual::Component>.
+For more help with using components, see L<DBIx::Class::Manual::Component/USING>.
=cut
Added: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/File.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/File.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/InflateColumn/File.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,205 @@
+package DBIx::Class::InflateColumn::File;
+
+use strict;
+use warnings;
+use base 'DBIx::Class';
+use File::Path;
+use File::Copy;
+use IO::File;
+
+__PACKAGE__->load_components(qw/InflateColumn/);
+
+
+sub register_column {
+ my ($self, $column, $info, @rest) = @_;
+ $self->next::method($column, $info, @rest);
+ return unless defined($info->{is_file_column});
+ $self->inflate_column(
+ $column =>
+ {
+ inflate => sub {
+ my ($value, $obj) = @_;
+ #$self->_inflate_file_column;
+ },
+ deflate => sub {
+ my ($value, $obj) = @_;
+ #my ( $file, @column_names ) = $self->_load_file_column_information;
+ #$self->_save_file_column( $file, $self, @column_names );
+ },
+ }
+ );
+}
+
+
+sub delete {
+ my ( $self, @rest ) = @_;
+
+ my @column_names = $self->columns;
+ for (@column_names) {
+ if ( $self->column_info($_)->{is_file_column} ) {
+ my $path =
+ File::Spec->catdir( $self->column_info($_)->{file_column_path},
+ $self->id );
+ rmtree( [$path], 0, 0 );
+ }
+ }
+
+ my $ret = $self->next::method(@rest);
+
+ return $ret;
+}
+
+sub _inflate_file_column {
+ my $self = shift;
+
+ my @column_names = $self->columns;
+ for(@column_names) {
+ if ( $self->column_info($_)->{is_file_column} ) {
+ # make sure everything checks out
+ unless (defined $self->$_) {
+ # if something is wrong set it to undef
+ $self->$_(undef);
+ next;
+ }
+ my $fs_file =
+ File::Spec->catfile( $self->column_info($_)->{file_column_path},
+ $self->id, $self->$_ );
+ $self->$_({handle => new IO::File($fs_file, "r"), filename => $self->$_});
+ }
+ }
+}
+
+sub _load_file_column_information {
+ my $self = shift;
+
+ my $file;
+ my @column_names;
+
+ @column_names = $self->columns;
+ for (@column_names) {
+ if ( $self->column_info($_)->{is_file_column} ) {
+ # make sure everything checks out
+ unless ((defined $self->$_) ||
+ (defined $self->$_->{filename} && defined $self->$_->{handle})) {
+ # if something is wrong set it to undef
+ $self->$_(undef);
+ next;
+ }
+ $file->{$_} = $self->$_;
+ $self->$_( $self->$_->{filename} );
+ }
+ }
+
+ return ( $file, @column_names );
+}
+
+sub _save_file_column {
+ my ( $self, $file, $ret, @column_names ) = @_;
+
+ for (@column_names) {
+ if ( $ret->column_info($_)->{is_file_column} ) {
+ next unless (defined $ret->$_);
+ my $file_path =
+ File::Spec->catdir( $ret->column_info($_)->{file_column_path},
+ $ret->id );
+ mkpath [$file_path];
+
+ my $outfile =
+ File::Spec->catfile( $file_path, $file->{$_}->{filename} );
+ File::Copy::copy( $file->{$_}->{handle}, $outfile );
+
+ $self->_file_column_callback($file->{$_},$ret,$_);
+ }
+ }
+}
+
+=head1 METHODS
+
+=cut
+
+
+=head2 _file_column_callback ($file,$ret,$target)
+
+method made to be overridden for callback purposes.
+
+=cut
+
+sub _file_column_callback {
+ my ($self,$file,$ret,$target) = @_;
+}
+
+=head1 NAME
+
+DBIx::Class::InflateColumn::File - map files from the Database to the filesystem.
+
+=head1 DESCRIPTION
+
+InflateColumn::File
+
+=head1 SYNOPSIS
+
+In your L<DBIx::Class> table class:
+
+ __PACKAGE__->load_components( "PK::Auto", "InflateColumn::File", "Core" );
+
+ # define your columns
+ __PACKAGE__->add_columns(
+ "id",
+ {
+ data_type => "integer",
+ is_auto_increment => 1,
+ is_nullable => 0,
+ size => 4,
+ },
+ "filename",
+ {
+ data_type => "varchar",
+ is_file_column => 1,
+ file_column_path =>'/tmp/uploaded_files',
+ # or for a Catalyst application
+ # file_column_path => MyApp->path_to('root','static','files'),
+ default_value => undef,
+ is_nullable => 1,
+ size => 255,
+ },
+ );
+
+
+In your L<Catalyst::Controller> class:
+
+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({
+ subject => 'blah',
+ filename => {
+ handle => $c->req->upload('myupload')->fh,
+ filename => $c->req->upload('myupload')->basename
+ },
+ body => '....'
+ });
+ $c->stash->{entry}=$entry;
+
+
+And Place the following in your TT template
+
+ Article Subject: [% entry.subject %]
+ Uploaded File:
+ <a href="/static/files/[% entry.id %]/[% entry.filename.filename %]">File</a>
+ Body: [% entry.body %]
+
+The file will be stored on the filesystem for later retrieval.
+Calling delete on your resultset will delete the file from the filesystem.
+Retrevial of the record automatically inflates the column back to the set hash with the IO::File handle and filename.
+
+=head1 AUTHOR
+
+Victor Igumnov
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Cookbook.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Cookbook.pod 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Cookbook.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -107,12 +107,15 @@
);
# Equivalent SQL:
- # SELECT name name, LENGTH( name ) name_length
+ # SELECT name name, LENGTH( name )
# FROM artist
-If your alias exists as a column in your base class (i.e. it was added
-with C<add_columns>), you just access it as normal. Our C<Artist>
-class has a C<name> column, so we just use the C<name> accessor:
+Note that the C< as > attribute has absolutely nothing to with the sql
+syntax C< SELECT foo AS bar > (see the documentation in
+L<DBIx::Class::ResultSet/ATTRIBUTES>). If your alias exists as a
+column in your base class (i.e. it was added with C<add_columns>), you
+just access it as normal. Our C<Artist> class has a C<name> column, so
+we just use the C<name> accessor:
my $artist = $rs->first();
my $name = $artist->name();
@@ -139,7 +142,7 @@
select => [
{ distinct => [ $source->columns ] }
],
- as => [ $source->columns ]
+ as => [ $source->columns ] # remember 'as' is not the same as SQL AS :-)
}
);
@@ -176,6 +179,10 @@
# LEFT JOIN cd cds ON ( cds.artist = me.artistid )
# GROUP BY name
+Please see L<DBIx::Class::ResultSet/ATTRIBUTES> documentation if you
+are in any way unsure about the use of the attributes above (C< join
+>, C< select >, C< as > and C< group_by >).
+
=head3 Predefined searches
You can write your own L<DBIx::Class::ResultSet> class by inheriting from it
@@ -415,7 +422,7 @@
{},
{
select => [ { sum => 'Cost' } ],
- as => [ 'total_cost' ],
+ as => [ 'total_cost' ], # remember this 'as' is for DBIx::Class::ResultSet not SQL
}
);
my $tc = $rs->first->get_column('total_cost');
@@ -526,7 +533,7 @@
=head2 Many-to-many relationships
-This is straightforward using L<DBIx::Class::Relationship::ManyToMany>:
+This is straightforward using L<ManyToMany|DBIx::Class::Relationship/many_to_many>:
package My::DB;
# ... set up connection ...
@@ -568,7 +575,9 @@
$attrs->{foo} = 'bar' unless defined $attrs->{foo};
- $class->next::method($attrs);
+ my $new = $class->next::method($attrs);
+
+ return $new;
}
For more information about C<next::method>, look in the L<Class::C3>
@@ -586,7 +595,7 @@
To make an object stringify itself as a single column, use something
like this (replace C<foo> with the column/method of your choice):
- use overload '""' => 'foo', fallback => 1;
+ use overload '""' => sub { shift->name}, fallback => 1;
For more complex stringification, you can use an anonymous subroutine:
@@ -1112,6 +1121,22 @@
Wasn't that easy?
+=head2 Get raw data for blindingly fast results
+
+If the C<inflate_result> solution above is not fast enough for you, you
+can use a DBIx::Class to return values exactly as they come out of the
+data base with none of the convenience methods wrapped round them.
+
+This is used like so:-
+
+ my $cursor = $rs->cursor
+ while (my @vals = $cursor->next) {
+ # use $val[0..n] here
+ }
+
+You will need to map the array offsets to particular columns (you can
+use the I<select> attribute of C<search()> to force ordering).
+
=head2 Want to know if find_or_create found or created a row?
Just use C<find_or_new> instead, then check C<in_storage>:
@@ -1122,4 +1147,43 @@
# do whatever else you wanted if it was a new row
}
+=head3 Wrapping/overloading a column accessor
+
+Problem: Say you have a table "Camera" and want to associate a description
+with each camera. For most cameras, you'll be able to generate the description from
+the other columns. However, in a few special cases you may want to associate a
+custom description with a camera.
+
+Solution:
+
+In your database schema, define a description field in the "Camera" table that
+can contain text and null values.
+
+In DBIC, we'll overload the column accessor to provide a sane default if no
+custom description is defined. The accessor will either return or generate the
+description, depending on whether the field is null or not.
+
+First, in your "Camera" schema class, define the description field as follows:
+
+ __PACKAGE__->add_columns(description => { accessor => '_description' });
+
+Next, we'll define the accessor-wrapper subroutine:
+
+ sub description {
+ my $self = shift;
+
+ # If there is an update to the column, we'll let the original accessor
+ # deal with it.
+ return $self->_description(@_) if @_;
+
+ # Fetch the column value.
+ my $description = $self->_description;
+
+ # If there's something in the description field, then just return that.
+ return $description if defined $description && length $descripton;
+
+ # Otherwise, generate a description.
+ return $self->generate_description;
+ }
+
=cut
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/FAQ.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/FAQ.pod 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/FAQ.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -255,6 +255,36 @@
L<DBIx::Class::ResultSetColumn>, see it's documentation and the
L<Cookbook|DBIx::Class::Manual::Cookbook> for details.
+=item .. fetch a formatted column?
+
+In your table schema class, create a "private" column accessor with:
+
+ __PACKAGE__->add_columns(my_common => { accessor => '_hidden_my_column' });
+
+Then, in the same class, implement a subroutine called "my_column" that
+fetches the real value and does the formatting you want.
+
+See the Cookbook for more details.
+
+=item .. fetch a single (or topmost) row?
+
+Sometimes you many only want a single record back from a search. A quick
+way to get that single row is to first run your search as usual:
+
+ ->search->(undef, { order_by => "id DESC" })
+
+Then call L<DBIx::Class::ResultSet/slice> and ask it only to return 1 row:
+
+ ->slice(0,1)
+
+These two calls can be combined into a single statement:
+
+ ->search->(undef, { order_by => "id DESC" })->slice(0,1)
+
+Why slice instead of L<DBIx::Class::ResultSet/first> or L<DBIx::Class::ResultSet/single>?
+If supported by the database, slice will use LIMIT/OFFSET to hint to the database that we
+really only need one row. This can result in a significant speed improvement.
+
=back
=head2 Inserting and updating data
@@ -296,6 +326,35 @@
->update({ somecolumn => \'othercolumn' })
+=item .. store JSON/YAML in a column and have it deflate/inflate automatically?
+
+You can use L<DBIx::Class::InflateColumn> to accomplish YAML/JSON storage transparently.
+
+If you want to use JSON, then in your table schema class, do the following:
+
+ use JSON;
+
+ __PACKAGE__->add_columns(qw/ ... my_column ../)
+ __PACKAGE__->inflate_column('my_column', {
+ inflate => sub { jsonToObj(shift) },
+ deflate => sub { objToJson(shift) },
+ });
+
+For YAML, in your table schema class, do the following:
+
+ use YAML;
+
+ __PACKAGE__->add_columns(qw/ ... my_column ../)
+ __PACKAGE__->inflate_column('my_column', {
+ inflate => sub { YAML::Load(shift) },
+ deflate => sub { YAML::Dump(shift) },
+ });
+
+This technique is an easy way to store supplemental unstructured data in a table. Be
+careful not to overuse this capability, however. If you find yourself depending more
+and more on some data within the inflated column, then it may be time to factor that
+data out.
+
=back
=head2 Misc
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Intro.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Intro.pod 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Intro.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -356,7 +356,7 @@
my $rs = $schema->resultset('Album')->search({
artist => { '!=', 'Janis Joplin' },
year => { '<' => 1980 },
- albumid => [ 1, 14, 15, 65, 43 ]
+ albumid => { '-in' => [ 1, 14, 15, 65, 43 ] }
});
This results in something like the following C<WHERE> clause:
Added: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Joining.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Joining.pod (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Joining.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,171 @@
+=head1 NAME
+
+DBIx::Class::Manual::Joining - Manual on joining tables with DBIx::Class
+
+=head1 DESCRIPTION
+
+This document should help you to use L<DBIx::Class> if you are trying
+to convert your normal SQL queries into DBIx::Class based queries, if
+you use joins extensively (and also probably if you don't).
+
+=head1 WHAT ARE JOINS
+
+If you ended up here and you don't actually know what joins are yet,
+then you should likely try the L<DBIx::Class::Manual::Intro>
+instead. Skip this part if you know what joins are..
+
+But I'll explain anyway. Assuming you have created your database in a
+more or less sensible way, you will end up with several tables that
+contain C<related> information. For example, you may have a table
+containing information about C<CDs>, containing the CD title and it's
+year of publication, and another table containing all the C<Track>s
+for the CDs, one track per row.
+
+When you wish to extract information about a particular CD and all
+it's tracks, You can either fetch the CD row, then make another query
+to fetch the tracks, or you can use a join. Compare:
+
+ SELECT ID, Title, Year FROM CD WHERE Title = 'Funky CD';
+ # .. Extract the ID, which is 10
+ SELECT Name, Artist FROM Tracks WHERE CDID = 10;
+
+ SELECT cd.ID, cd.Title, cd.Year, tracks.Name, tracks.Artist FROM CD JOIN Tracks ON CD.ID = tracks.CDID WHERE cd.Title = 'Funky CD';
+
+So, joins are a way of extending simple select statements to include
+fields from other, related, tables. There are various types of joins,
+depending on which combination of the data you wish to retrieve, see
+L<MySQL's doc on JOINs|http://dev.mysql.com/doc/refman/5.0/en/join.html>.
+
+=head1 DEFINING JOINS AND RELATIONSHIPS
+
+In L<DBIx::Class> each relationship between two tables needs to first
+be defined in the L<ResultSource|DBIx::Class::Manual::Glossary/ResultSource> for the
+table. If the relationship needs to be accessed in both directions
+(i.e. Fetch all tracks of a CD, and fetch the CD data for a Track),
+then it needs to be defined in both tables.
+
+For the CDs/Tracks example, that means writing, in C<MySchema::CD>:
+
+ MySchema::CD->has_many('tracks', 'MySchema::Tracks');
+
+And in C<MySchema::Tracks>:
+
+ MySchema::Tracks->belongs_to('cd', 'MySchema::CD', 'CDID');
+
+There are several other types of relationships, they are more
+comprehensively described in L<DBIx::Class::Relationship>.
+
+=head1 USING JOINS
+
+Once you have defined all your relationships, using them in actual
+joins is fairly simple. The type of relationship that you chose
+e.g. C<has_many>, already indicates what sort of join will be
+performed. C<has_many> produces a C<LEFT JOIN> for example, which will
+fetch all the rows on the left side, whether there are matching rows
+on the right (table being joined to), or not. You can force other
+types of joins in your relationship, see the
+L<DBIx::Class::Relationship> docs.
+
+When performing either a L<search|DBIx::Class::ResultSet/search> or a
+L<find|DBIx::Class::ResultSet/find> operation, you can specify which
+C<relations> to also fetch data from (or sort by), using the
+L<join|DBIx::Class::ResultSet/join> attribute, like this:
+
+ $schema->resultset('CD')->search(
+ { 'Title' => 'Funky CD' },
+ { join => 'tracks',
+ '+select' => [ 'tracks.Name', 'tracks.Artist' ],
+ '+as' => [ 'TrackName', 'ArtistName' ]
+ }
+ );
+
+If you don't recognise most of this syntax, you should probably go
+read L<DBIx::Class::ResultSet/search> and
+L<DBIx::Class::ResultSet/ATTRIBUTES>, but here's a quick break down:
+
+The first argument to search is a hashref of the WHERE attributes, in
+this case a simple restriction on the Title column. The second
+argument is a hashref of attributes to the search, '+select' adds
+extra columns to the select (from the joined table(s) or from
+calculations), and '+as' gives aliases to those fields.
+
+'join' specifies which C<relationships> to include in the query. The
+distinction between C<relationships> and C<tables> is important here,
+only the C<relationship> names are valid.
+
+This example should magically produce SQL like the second select in
+L</WHAT ARE JOINS> above.
+
+=head1 COMPLEX JOINS AND STUFF
+
+=head2 Across multiple relations
+
+For simplicity in the example above, the C<Artist> was shown as a
+simple text firld in the C<Tracks> table, in reality, you'll want to
+have the artists in their own table as well, thus to fetch the
+complete set of data we'll need to join to the Artist table too.
+
+In C<MySchema::Tracks>:
+
+ MySchema::Tracks->belongs_to('artist', 'MySchema::Artist', 'ArtistID');
+
+The search:
+
+ $schema->resultset('CD')->search(
+ { 'Title' => 'Funky CD' },
+ { join => { 'tracks' => 'artist' },
+ '+select' => [ 'tracks.Name', 'artist.Artist' ],
+ '+as' => [ 'TrackName', 'ArtistName' ]
+ }
+ );
+
+Which is:
+
+ SELECT me.ID, me.Title, me.Year, tracks.Name, artist.Artist FROM CD me JOIN Tracks tracks ON CD.ID = tracks.CDID JOIN Artists artist ON tracks.ArtistID = artist.ID WHERE me.Title = 'Funky CD';
+
+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!):
+
+ join => { room => { table => 'leg' } }
+
+To join two relations at the same level, use an arrayref instead:
+
+ join => { room => [ 'chair', 'table' ] }
+
+Or combine the two:
+
+ join => { room => [ 'chair', { table => 'leg' } ]
+
+=head2 Table aliases
+
+As an aside to all the discussion on joins, note that L<DBIx::Class>
+uses the C<relation names> as table aliases. This is important when
+you need to add grouping or ordering to your queries:
+
+ $schema->resultset('CD')->search(
+ { 'Title' => 'Funky CD' },
+ { join => { 'tracks' => 'artist' },
+ order_by => [ 'tracks.Name', 'artist.Artist' ],
+ '+select' => [ 'tracks.Name', 'artist.Artist' ],
+ '+as' => [ 'TrackName', 'ArtistName' ]
+ }
+ );
+
+ SELECT me.ID, me.Title, me.Year, tracks.Name, artist.Artist FROM CD me JOIN Tracks tracks ON CD.ID = tracks.CDID JOIN Artists artist ON tracks.ArtistID = artist.ID WHERE me.Title = 'Funky CD' ORDER BY tracks.Name, artist.Artist;
+
+This is essential if any of your tables have columns with the same names.
+
+Note that the table of the resultsource the search was performed on, is always aliased to C<me>.
+
+=head2 Joining to the same table twice
+
+There is no magic to this, just do it. The table aliases will
+automatically be numbered:
+
+ join => [ 'room', 'room' ]
+
+The aliases are: C<room_1> and C<room_2>.
+
+=cut
+
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Troubleshooting.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Troubleshooting.pod 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual/Troubleshooting.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -47,5 +47,13 @@
L<DBI> version 1.50 and L<DBD::Pg> 1.43 are known to work.
+=head2 ... Can't locate object method "source_name" via package ...
+
+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, so for a schema C< MySchema > you need to
+specify a fully qualified namespace: C< package MySchema::MyTable; >
+for example.
+
=cut
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual.pod
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual.pod 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Manual.pod 2007-05-10 21:30:41 UTC (rev 3283)
@@ -11,6 +11,10 @@
=head1 SECTIONS
+=head2 L<DBIx::Class::Manual::FAQ>
+
+Short answers and doc pointers to questions.
+
=head2 L<DBIx::Class::Manual::Intro>
Beginner guide to using DBIx::Class.
@@ -19,6 +23,10 @@
An example of slightly more complex usage.
+=head2 L<DBIx::Class::Manual::Joining>
+
+How to translate known SQL JOINs into DBIx-Class-ish.
+
=head2 L<DBIx::Class::Manual::Cookbook>
Convenient recipes for DBIC usage.
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Ordered.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Ordered.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Ordered.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -38,7 +38,7 @@
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 ... ));
@@ -57,7 +57,7 @@
__PACKAGE__->grouping_column(['group_id', 'other_group_id']);
-Thats it, now you can change the position of your objects.
+That's it, now you can change the position of your objects.
#!/use/bin/perl
use My::Item;
@@ -103,7 +103,7 @@
__PACKAGE__->position_column('position');
Sets and retrieves the name of the column that stores the
-positional value of each record. Default to "position".
+positional value of each record. Defaults to "position".
=cut
@@ -113,7 +113,7 @@
__PACKAGE__->grouping_column('group_id');
-This method specified a column to limit all queries in
+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.
@@ -126,7 +126,7 @@
my $rs = $item->siblings();
my @siblings = $item->siblings();
-Returns either a result set or an array of all other objects
+Returns either a resultset or an array of all other objects
excluding the one you called it on.
=cut
@@ -150,7 +150,7 @@
my $sibling = $item->first_sibling();
Returns the first sibling object, or 0 if the first sibling
-is this sibliing.
+is this sibling.
=cut
@@ -170,7 +170,7 @@
my $sibling = $item->last_sibling();
-Return 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
@@ -191,8 +191,8 @@
my $sibling = $item->previous_sibling();
-Returns the sibling that resides one position back. Undef
-is returned if the current object is the first one.
+Returns the sibling that resides one position back. Returns undef
+if the current object is the first one.
=cut
@@ -213,8 +213,8 @@
my $sibling = $item->next_sibling();
-Returns the sibling that resides one position foward. Undef
-is returned if the current object is the last one.
+Returns the sibling that resides one position forward. Returns undef
+if the current object is the last one.
=cut
@@ -236,9 +236,9 @@
$item->move_previous();
-Swaps position with the sibling on position previous in the list.
-1 is returned on success, and 0 is returned if the objects is already
-the first one.
+Swaps position with the sibling in the position previous in
+the list. Returns 1 on success, and 0 if the object is
+already the first one.
=cut
@@ -252,8 +252,9 @@
$item->move_next();
-Swaps position with the sibling in the next position. 1 is returned on
-success, and 0 is returned if the object is already the last in the list.
+Swaps position with the sibling in the next position in the
+list. Returns 1 on success, and 0 if the object is already
+the last in the list.
=cut
@@ -269,8 +270,8 @@
$item->move_first();
-Moves the object to the first position. 1 is returned on
-success, and 0 is returned if the object is already the first.
+Moves the object to the first position in the list. Returns 1
+on success, and 0 if the object is already the first.
=cut
@@ -283,8 +284,8 @@
$item->move_last();
-Moves the object to the very last position. 1 is returned on
-success, and 0 is returned if the object is already the last one.
+Moves the object to the last position in the list. Returns 1
+on success, and 0 if the object is already the last one.
=cut
@@ -298,9 +299,9 @@
$item->move_to( $position );
-Moves the object to the specified position. 1 is returned on
-success, and 0 is returned if the object is already at the
-specified position.
+Moves the object to the specified position. Returns 1 on
+success, and 0 if the object is already at the specified
+position.
=cut
@@ -539,7 +540,7 @@
If a position is not specified for an insert than a position
will be chosen based on COUNT(*)+1. But, it first selects the
-count then inserts the record. The space of time between select
+count, and then inserts the record. The space of time between select
and insert introduces a race condition. To fix this we need the
ability to lock tables in DBIC. I've added an entry in the TODO
about this.
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship/Base.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship/Base.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship/Base.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -102,6 +102,13 @@
a column accessor). For C<multi> accessors, an add_to_* method is also
created, which calls C<create_related> for the relationship.
+=item is_foreign_key_constraint
+
+If you are using L<SQL::Translator> to create SQL for you and you find that it
+is creating constraints where it shouldn't, or not creating them where it
+should, set this attribute to a true or false value to override the detection
+of when to create constraints.
+
=back
=head2 register_relationship
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Relationship.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -308,6 +308,11 @@
My::DBIC::Schema::Role->many_to_many( actors => 'actor_roles', 'actor' );
+To add a role for your actor, and fill in the year of the role in the
+actor_roles table:
+
+ $actor->add_to_roles($role, { year => 1995 });
+
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
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSet.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSet.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSet.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -135,7 +135,10 @@
columns => [qw/name artistid/],
});
-For a list of attributes that can be passed to C<search>, see L</ATTRIBUTES>. For more examples of using this function, see L<Searching|DBIx::Class::Manual::Cookbook/Searching>.
+For a list of attributes that can be passed to C<search>, see
+L</ATTRIBUTES>. For more examples of using this function, see
+L<Searching|DBIx::Class::Manual::Cookbook/Searching>. For a complete
+documentation for the first argument, see L<SQL::Abstract>.
=cut
@@ -1273,9 +1276,10 @@
my %new = (
%{ $self->_remove_alias($values, $alias) },
%{ $self->_remove_alias($collapsed_cond, $alias) },
+ -source_handle => $self->_source_handle
);
- return $self->result_class->new(\%new,$self->_source_handle);
+ return $self->result_class->new(\%new);
}
# _collapse_cond
@@ -1825,7 +1829,9 @@
});
would return all CDs and include a 'name' column to the information
-passed to object inflation
+passed to object inflation. Note that the 'artist' is the name of the
+column (or relationship) accessor, and 'name' is the name of the column
+accessor in the related table.
=head2 select
@@ -1876,8 +1882,14 @@
=back
-Indicates column names for object inflation. This is used in conjunction with
-C<select>, usually when C<select> contains one or more function or stored
+Indicates column names for object inflation. That is, c< as >
+indicates the name that the column can be accessed as via the
+C<get_column> method (or via the object accessor, B<if one already
+exists>). It has nothing to do with the SQL code C< SELECT foo AS bar
+>.
+
+The C< as > attribute is used in conjunction with C<select>,
+usually when C<select> contains one or more function or stored
procedure names:
$rs = $schema->resultset('Employee')->search(undef, {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSource.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSource.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/ResultSource.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -14,7 +14,7 @@
_columns _primaries _unique_constraints name resultset_attributes
schema from _relationships column_info_from_storage source_info/);
-__PACKAGE__->mk_group_accessors('inherited' => qw/resultset_class
+__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class
result_class/);
__PACKAGE__->mk_group_ro_accessors('simple' => qw/source_name/);
@@ -957,7 +957,9 @@
$source->resultset_attributes({ order_by => [ 'id' ] });
-Specify here any attributes you wish to pass to your specialised resultset.
+Specify here any attributes you wish to pass to your specialised
+resultset. For a full list of these, please see
+L<DBIx::Class::ResultSet/ATTRIBUTES>.
=cut
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Row.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Row.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Row.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -30,13 +30,18 @@
=cut
sub new {
- my ($class, $attrs, $source) = @_;
+ my ($class, $attrs) = @_;
$class = ref $class if ref $class;
my $new = { _column_data => {} };
bless $new, $class;
- $new->_source_handle($source) if $source;
+ if (my $handle = delete $attrs->{-source_handle}) {
+ $new->_source_handle($handle);
+ }
+ if (my $source = delete $attrs->{-result_source}) {
+ $new->result_source($source);
+ }
if ($attrs) {
$new->throw_exception("attrs must be a hashref")
@@ -64,9 +69,6 @@
unless $class->has_column($key);
$new->store_column($key => $attrs->{$key});
}
- if (my $source = delete $attrs->{-result_source}) {
- $new->result_source($source);
- }
$new->{_relationship_data} = $related if $related;
$new->{_inflated_column} = $inflated if $inflated;
@@ -121,12 +123,16 @@
=head2 update
- $obj->update;
+ $obj->update \%columns?;
Must be run on an object that is already in the database; issues an SQL
UPDATE query to commit any changes to the object to the database if
required.
+Also takes an options hashref of C<< column_name => value> pairs >> to update
+first. But be aware that this hashref might be edited in place, so dont rely on
+it being the same after a call to C<update>.
+
=cut
sub update {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Schema.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Schema.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Schema.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -578,9 +578,6 @@
sub compose_namespace {
my ($self, $target, $base) = @_;
- my %reg = %{ $self->source_registrations };
- my %target;
- my %map;
my $schema = $self->clone;
{
no warnings qw/redefine/;
@@ -1007,7 +1004,7 @@
my ($self, $type, $dir, $version, $pversion) = @_;
my $filename = ref($self);
- $filename =~ s/::/-/;
+ $filename =~ s/::/-/g;
$filename = File::Spec->catfile($dir, "$filename-$version-$type.sql");
$filename =~ s/$version/$pversion-$version/ if($pversion);
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Cursor.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Cursor.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Cursor.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -59,7 +59,8 @@
=back
-Advances the cursor to the next row and returns an arrayref of column values.
+Advances the cursor to the next row and returns an array of column
+values (the result of L<DBI/fetchrow_array> method).
=cut
Added: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,83 @@
+package DBIx::Class::Storage::DBI::Oracle::Generic;
+# -*- mode: cperl; cperl-indent-level: 2 -*-
+
+use strict;
+use warnings;
+
+use Carp::Clan qw/^DBIx::Class/;
+
+use base qw/DBIx::Class::Storage::DBI::MultiDistinctEmulation/;
+
+# __PACKAGE__->load_components(qw/PK::Auto/);
+
+sub _dbh_last_insert_id {
+ my ($self, $dbh, $source, $col) = @_;
+ my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
+ my $sql = 'SELECT ' . $seq . '.currval FROM DUAL';
+ my ($id) = $dbh->selectrow_array($sql);
+ return $id;
+}
+
+sub _dbh_get_autoinc_seq {
+ my ($self, $dbh, $source, $col) = @_;
+
+ # look up the correct sequence automatically
+ my $sql = q{
+ SELECT trigger_body FROM ALL_TRIGGERS t
+ WHERE t.table_name = ?
+ AND t.triggering_event = 'INSERT'
+ AND t.status = 'ENABLED'
+ };
+
+ # trigger_body is a LONG
+ $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute( uc($source->name) );
+ while (my ($insert_trigger) = $sth->fetchrow_array) {
+ return uc($1) if $insert_trigger =~ m!(\w+)\.nextval!i; # col name goes here???
+ }
+ croak "Unable to find a sequence INSERT trigger on table '" . $source->name . "'.";
+}
+
+sub get_autoinc_seq {
+ my ($self, $source, $col) = @_;
+
+ $self->dbh_do($self->can('_dbh_get_autoinc_seq'), $source, $col);
+}
+
+sub columns_info_for {
+ my ($self, $table) = @_;
+
+ $self->next::method(uc($table));
+}
+
+
+1;
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::Oracle - Automatic primary key class for Oracle
+
+=head1 SYNOPSIS
+
+ # In your table classes
+ __PACKAGE__->load_components(qw/PK::Auto Core/);
+ __PACKAGE__->set_primary_key('id');
+ __PACKAGE__->sequence('mysequence');
+
+=head1 DESCRIPTION
+
+This class implements autoincrements for Oracle.
+
+=head1 AUTHORS
+
+Andy Grundman <andy at hybridized.org>
+
+Scott Connelly <scottsweep at yahoo.com>
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut
Added: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/WhereJoins.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/WhereJoins.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle/WhereJoins.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,185 @@
+package DBIx::Class::Storage::DBI::Oracle::WhereJoins;
+
+use base qw( DBIx::Class::Storage::DBI::Oracle::Generic );
+
+use strict;
+use warnings;
+
+BEGIN {
+ package DBIC::SQL::Abstract::Oracle;
+
+ use base qw( DBIC::SQL::Abstract );
+
+ sub select {
+ my ($self, $table, $fields, $where, $order, @rest) = @_;
+
+ $self->_oracle_joins($where, @{ $table });
+
+ return $self->SUPER::select($table, $fields, $where, $order, @rest);
+ }
+
+ sub _recurse_from {
+ my ($self, $from, @join) = @_;
+
+ my @sqlf = $self->_make_as($from);
+
+ foreach my $j (@join) {
+ my ($to, $on) = @{ $j };
+
+ if (ref $to eq 'ARRAY') {
+ push (@sqlf, $self->_recurse_from(@{ $to }));
+ }
+ else {
+ push (@sqlf, $self->_make_as($to));
+ }
+ }
+
+ return join q{, }, @sqlf;
+ }
+
+ sub _oracle_joins {
+ my ($self, $where, $from, @join) = @_;
+
+ foreach my $j (@join) {
+ my ($to, $on) = @{ $j };
+
+ if (ref $to eq 'ARRAY') {
+ $self->_oracle_joins($where, @{ $to });
+ }
+
+ my $to_jt = ref $to eq 'ARRAY' ? $to->[0] : $to;
+ my $left_join = q{};
+ my $right_join = q{};
+
+ if (ref $to_jt eq 'HASH' and exists $to_jt->{-join_type}) {
+ #TODO: Support full outer joins -- this would happen much earlier in
+ #the sequence since oracle 8's full outer join syntax is best
+ #described as INSANE.
+ die "Can't handle full outer joins in Oracle 8 yet!\n"
+ if $to_jt->{-join_type} =~ /full/i;
+
+ $left_join = q{(+)} if $to_jt->{-join_type} =~ /right/i
+ && $to_jt->{-join_type} !~ /inner/i;
+
+ $right_join = q{(+)} if $to_jt->{-join_type} =~ /left/i
+ && $to_jt->{-join_type} !~ /inner/i;
+ }
+
+ foreach my $lhs (keys %{ $on }) {
+ $where->{$lhs . $left_join} = \" = $on->{ $lhs }$right_join";
+ }
+ }
+ }
+}
+
+sub sql_maker {
+ my ($self) = @_;
+
+ unless ($self->_sql_maker) {
+ $self->_sql_maker(
+ new DBIC::SQL::Abstract::Oracle( $self->_sql_maker_args )
+ );
+ }
+
+ return $self->_sql_maker;
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::Oracle::WhereJoins - Oracle joins in WHERE syntax
+support (instead of ANSI).
+
+=head1 PURPOSE
+
+This module was originally written to support Oracle < 9i where ANSI joins
+weren't supported at all, but became the module for Oracle >= 8 because
+Oracle's optimising of ANSI joins is horrible. (See:
+http://scsys.co.uk:8001/7495)
+
+=head1 SYNOPSIS
+
+DBIx::Class should automagically detect Oracle and use this module with no
+work from you.
+
+=head1 DESCRIPTION
+
+This class implements Oracle's WhereJoin support. Instead of:
+
+ SELECT x FROM y JOIN z ON y.id = z.id
+
+It will write:
+
+ SELECT x FROM y, z WHERE y.id = z.id
+
+It should properly support left joins, and right joins. Full outer joins are
+not possible due to the fact that Oracle requires the entire query be written
+to union the results of a left and right join, and by the time this module is
+called to create the where query and table definition part of the sql query,
+it's already too late.
+
+=head1 METHODS
+
+This module replaces a subroutine contained in DBIC::SQL::Abstract:
+
+=over
+
+=item sql_maker
+
+=back
+
+It also creates a new module in its BEGIN { } block called
+DBIC::SQL::Abstract::Oracle which has the following methods:
+
+=over
+
+=item select ($\@$;$$@)
+
+Replaces DBIC::SQL::Abstract's select() method, which calls _oracle_joins()
+to modify the column and table list before calling SUPER::select().
+
+=item _recurse_from ($$\@)
+
+Recursive subroutine that builds the table list.
+
+=item _oracle_joins ($$$@)
+
+Creates the left/right relationship in the where query.
+
+=back
+
+=head1 BUGS
+
+Does not support full outer joins.
+Probably lots more.
+
+=head1 SEE ALSO
+
+=over
+
+=item L<DBIC::SQL::Abstract>
+
+=item L<DBIx::Class::Storage::DBI::Oracle::Generic>
+
+=item L<DBIx::Class>
+
+=back
+
+=head1 AUTHOR
+
+Justin Wheeler C<< <jwheeler at datademons.com> >>
+
+=head1 CONTRIBUTORS
+
+David Jack Olrik C<< <djo at cpan.org> >>
+
+=head1 LICENSE
+
+This module is licensed under the same terms as Perl itself.
+
+=cut
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Oracle.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -3,78 +3,50 @@
use strict;
use warnings;
-use Carp::Clan qw/^DBIx::Class/;
+use base qw/DBIx::Class::Storage::DBI/;
-use base qw/DBIx::Class::Storage::DBI::MultiDistinctEmulation/;
+sub _rebless {
+ my ($self) = @_;
-# __PACKAGE__->load_components(qw/PK::Auto/);
+ my $version = eval { $self->_dbh->get_info(18); };
-sub _dbh_last_insert_id {
- my ($self, $dbh, $source, $col) = @_;
- my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
- my $sql = 'SELECT ' . $seq . '.currval FROM DUAL';
- my ($id) = $dbh->selectrow_array($sql);
- return $id;
-}
+ if ( !$@ ) {
+ my ($major, $minor, $patchlevel) = split(/\./, $version);
-sub _dbh_get_autoinc_seq {
- my ($self, $dbh, $source, $col) = @_;
+ # Default driver
+ my $class = $major >= 8
+ ? 'DBIx::Class::Storage::DBI::Oracle::WhereJoins'
+ : 'DBIx::Class::Storage::DBI::Oracle::Generic';
- # look up the correct sequence automatically
- my $sql = q{
- SELECT trigger_body FROM ALL_TRIGGERS t
- WHERE t.table_name = ?
- AND t.triggering_event = 'INSERT'
- AND t.status = 'ENABLED'
- };
+ # Load and rebless
+ eval "require $class";
- # trigger_body is a LONG
- $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
-
- my $sth = $dbh->prepare($sql);
- $sth->execute( uc($source->name) );
- while (my ($insert_trigger) = $sth->fetchrow_array) {
- return uc($1) if $insert_trigger =~ m!(\w+)\.nextval!i; # col name goes here???
- }
- croak "Unable to find a sequence INSERT trigger on table '" . $source->name . "'.";
+ bless $self, $class unless $@;
+ }
}
-sub get_autoinc_seq {
- my ($self, $source, $col) = @_;
-
- $self->dbh_do($self->can('_dbh_get_autoinc_seq'), $source, $col);
-}
-sub columns_info_for {
- my ($self, $table) = @_;
-
- $self->next::method(uc($table));
-}
-
-
1;
=head1 NAME
-DBIx::Class::Storage::DBI::Oracle - Automatic primary key class for Oracle
+DBIx::Class::Storage::DBI::Oracle - Base class for Oracle driver
=head1 SYNOPSIS
# In your table classes
- __PACKAGE__->load_components(qw/PK::Auto Core/);
- __PACKAGE__->set_primary_key('id');
- __PACKAGE__->sequence('mysequence');
+ __PACKAGE__->load_components(qw/Core/);
=head1 DESCRIPTION
-This class implements autoincrements for Oracle.
+This class simply provides a mechanism for discovering and loading a sub-class
+for a specific version Oracle backend. It should be transparent to the user.
+
=head1 AUTHORS
-Andy Grundman <andy at hybridized.org>
+David Jack Olrik C<< <djo at cpan.org> >>
-Scott Connelly <scottsweep at yahoo.com>
-
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Pg.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/Pg.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -62,7 +62,7 @@
my ($self,$data_type) = @_;
my $bind_attributes = {
- bytea => { pg_type => DBD::Pg::PG_BYTEA },
+ bytea => { pg_type => DBD::Pg::PG_BYTEA },
};
if( defined $bind_attributes->{$data_type} ) {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/SQLite.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/SQLite.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI/SQLite.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -45,6 +45,15 @@
return $backupfile;
}
+sub txn_begin
+{
+ my $self = shift;
+ return if(!$self->{transaction_depth});
+
+ $self->next::method(@_);
+}
+
+
1;
=head1 NAME
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage/DBI.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -3,7 +3,7 @@
use base 'DBIx::Class::Storage';
-use strict;
+use strict;
use warnings;
use DBI;
use SQL::Abstract::Limit;
@@ -506,7 +506,9 @@
ref $coderef eq 'CODE' or $self->throw_exception
('$coderef must be a CODE reference');
- return $coderef->($self, $self->_dbh, @_) if $self->{_in_dbh_do};
+ return $coderef->($self, $self->_dbh, @_) if $self->{_in_dbh_do}
+ || $self->{transaction_depth};
+
local $self->{_in_dbh_do} = 1;
my @result;
@@ -829,8 +831,7 @@
sub _execute {
my ($self, $op, $extra_bind, $ident, $bind_attributes, @args) = @_;
- if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") )
- {
+ if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
$ident = $ident->from();
}
@@ -843,49 +844,55 @@
map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @bind;
$self->debugobj->query_start($sql, @debug_bind);
}
- my $sth = eval { $self->sth($sql,$op) };
- if (!$sth || $@) {
- $self->throw_exception(
- 'no sth generated via sql (' . ($@ || $self->_dbh->errstr) . "): $sql"
- );
- }
+ my ($rv, $sth);
+ RETRY: while (1) {
+ $sth = eval { $self->sth($sql,$op) };
- my $rv;
- if ($sth) {
- my $time = time();
-
- $rv = eval {
-
- my $placeholder_index = 1;
+ if (!$sth || $@) {
+ $self->throw_exception(
+ 'no sth generated via sql (' . ($@ || $self->_dbh->errstr) . "): $sql"
+ );
+ }
- foreach my $bound (@bind) {
+ if ($sth) {
+ my $time = time();
+ $rv = eval {
+ my $placeholder_index = 1;
- my $attributes = {};
- my($column_name, @data) = @$bound;
+ foreach my $bound (@bind) {
- if( $bind_attributes ) {
- $attributes = $bind_attributes->{$column_name}
- if defined $bind_attributes->{$column_name};
- }
+ my $attributes = {};
+ my($column_name, @data) = @$bound;
- foreach my $data (@data)
- {
- $data = ref $data ? ''.$data : $data; # stringify args
+ if( $bind_attributes ) {
+ $attributes = $bind_attributes->{$column_name}
+ if defined $bind_attributes->{$column_name};
+ }
- $sth->bind_param($placeholder_index, $data, $attributes);
- $placeholder_index++;
- }
+ foreach my $data (@data)
+ {
+ $data = ref $data ? ''.$data : $data; # stringify args
+
+ $sth->bind_param($placeholder_index, $data, $attributes);
+ $placeholder_index++;
+ }
+ }
+ $sth->execute();
+ };
+
+ if ($@ || !$rv) {
+ $self->throw_exception("Error executing '$sql': ".($@ || $sth->errstr))
+ if $self->connected;
+ $self->_populate_dbh;
+ } else {
+ last RETRY;
}
- $sth->execute();
- };
-
- if ($@ || !$rv) {
- $self->throw_exception("Error executing '$sql': ".($@ || $sth->errstr));
+ } else {
+ $self->throw_exception("'$sql' did not generate a statement.");
}
- } else {
- $self->throw_exception("'$sql' did not generate a statement.");
- }
+ } # While(1) to retry if disconencted
+
if ($self->debug) {
my @debug_bind =
map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @bind;
@@ -935,32 +942,17 @@
##use Data::Dumper;
##print STDERR Dumper( $data, $sql, [@bind] );
-
+
if ($sth) {
my $time = time();
-
- #$rv = eval {
- #
- # $sth->execute_array({
- # ArrayTupleFetch => sub {
-
- # my $values = shift @$data;
- # return if !$values;
- # return [ @{$values}[@bind] ];
- # },
-
- # ArrayTupleStatus => $tuple_status,
- # })
- #};
-
- ## Get the bind_attributes, if any exist
+ ## Get the bind_attributes, if any exist
my $bind_attributes = $self->source_bind_attributes($source);
- ## Bind the values and execute
- $rv = eval {
-
+ ## Bind the values and execute
+ $rv = eval {
+
my $placeholder_index = 1;
foreach my $bound (@bind) {
@@ -972,20 +964,19 @@
$attributes = $bind_attributes->{$column_name}
if defined $bind_attributes->{$column_name};
}
-
- my @data = map { $_->[$data_index] } @$data;
+ my @data = map { $_->[$data_index] } @$data;
+
$sth->bind_param_array( $placeholder_index, [@data], $attributes );
$placeholder_index++;
}
- $sth->execute_array( {ArrayTupleStatus => $tuple_status} );
+ $sth->execute_array( {ArrayTupleStatus => $tuple_status} );
- };
+ };
if ($@ || !defined $rv) {
my $errors = '';
- foreach my $tuple (@$tuple_status)
- {
+ foreach my $tuple (@$tuple_status) {
$errors .= "\n" . $tuple->[1] if(ref $tuple);
}
$self->throw_exception("Error executing '$sql': ".($@ || $errors));
@@ -1052,7 +1043,7 @@
my $data_type = $source->column_info($column)->{data_type} || '';
$bind_attributes->{$column} = $self->bind_attribute_by_data_type($data_type)
- if $data_type;
+ if $data_type;
}
return $bind_attributes;
@@ -1142,18 +1133,12 @@
}
my %result;
- my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0");
+ my $sth = $dbh->prepare($self->sql_maker->select($table, undef, \'1 = 0'));
$sth->execute;
my @columns = @{$sth->{NAME_lc}};
for my $i ( 0 .. $#columns ){
my %column_info;
- my $type_num = $sth->{TYPE}->[$i];
- my $type_name;
- if(defined $type_num && $dbh->can('type_info')) {
- my $type_info = $dbh->type_info($type_num);
- $type_name = $type_info->{TYPE_NAME} if $type_info;
- }
- $column_info{data_type} = $type_name ? $type_name : $type_num;
+ $column_info{data_type} = $sth->{TYPE}->[$i];
$column_info{size} = $sth->{PRECISION}->[$i];
$column_info{is_nullable} = $sth->{NULLABLE}->[$i] ? 1 : 0;
@@ -1164,7 +1149,19 @@
$result{$columns[$i]} = \%column_info;
}
+ $sth->finish;
+ foreach my $col (keys %result) {
+ my $colinfo = $result{$col};
+ my $type_num = $colinfo->{data_type};
+ my $type_name;
+ if(defined $type_num && $dbh->can('type_info')) {
+ my $type_info = $dbh->type_info($type_num);
+ $type_name = $type_info->{TYPE_NAME} if $type_info;
+ $colinfo->{data_type} = $type_name if $type_name;
+ }
+ }
+
return \%result;
}
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class/Storage.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -169,6 +169,15 @@
the outermost transaction will issue a L</txn_commit>, and txn_do() can be
called in void, scalar and list context and it will behave as expected.
+Please note that all of the code in your coderef, including non-DBIx::Class
+code, is part of a transaction. This transaction may fail out halfway, or
+it may get partially double-executed (in the case that our DB connection
+failed halfway through the transaction, in which case we reconnect and
+restart the txn). Therefore it is best that any side-effects in your coderef
+are idempotent (that is, can be re-executed multiple times and get the
+same result), and that you check up on your side-effects in the case of
+transaction failure.
+
=cut
sub txn_do {
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/DBIx/Class.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -18,7 +18,7 @@
# i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
# brain damage and presumably various other packaging systems too
-$VERSION = '0.07999_01';
+$VERSION = '0.07999_02';
sub MODIFY_CODE_ATTRIBUTES {
my ($class,$code, at attrs) = @_;
@@ -199,8 +199,12 @@
clkao: CL Kao
+da5id: David Jack Olrik <djo at cpan.org>
+
dkubb: Dan Kubb <dan.kubb-cpan at onautopilot.com>
+dnm: Justin Wheeler <jwheeler at datademons.com>
+
draven: Marcus Ramberg <mramberg at cpan.org>
dwc: Daniel Westermann-Clark <danieltwc at cpan.org>
@@ -213,6 +217,8 @@
jguenther: Justin Guenther <jguenther at cpan.org>
+jshirley: J. Shirley <jshirley at gmail.com>
+
konobi: Scott McWhirter
LTJake: Brian Cassidy <bricas at cpan.org>
Modified: branches/DBIx-Class/collapse_result_rewrite/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/lib/SQL/Translator/Parser/DBIx/Class.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/lib/SQL/Translator/Parser/DBIx/Class.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -145,16 +145,18 @@
#Decide if this is a foreign key based on whether the self
#items are our primary columns.
+ $DB::single = 1 if $moniker eq 'Tests::MBTI::Result';
# If the sets are different, then we assume it's a foreign key from
# us to another table.
- # OR: If is_foreign_key attr is explicity set on one the local columns
- if ( ! exists $created_FK_rels{$rel_table}->{$key_test}
- &&
- ( !$source->compare_relationship_keys(\@keys, \@primary) ||
- grep { $source->column_info($_)->{is_foreign_key} } @keys
- )
- ) {
+ # OR: If is_foreign_key_constraint attr is explicity set (or set to false) on the relation
+ if ( ! exists $created_FK_rels{$rel_table}->{$key_test} &&
+ ( exists $rel_info->{attrs}{is_foreign_key_constraint} &&
+ $rel_info->{attrs}{is_foreign_key_constraint} ||
+ !$source->compare_relationship_keys(\@keys, \@primary)
+ )
+ )
+ {
$created_FK_rels{$rel_table}->{$key_test} = 1;
$table->add_constraint(
type => 'foreign_key',
Modified: branches/DBIx-Class/collapse_result_rewrite/t/76joins.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/76joins.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/76joins.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -105,7 +105,7 @@
[ { father => 'person' }, { 'father.person_id' => { '!=', '42' } }, ],
[ { mother => 'person' }, { 'mother.person_id' => 'child.mother_id' } ],
);
-$match = qr/^\QHASH reference arguments are not supported in JOINS - try using \"..." instead\E/;
+$match = qr/^HASH reference arguments are not supported in JOINS - try using "\.\.\." instead/;
eval { $sa->_recurse_from(@j6) };
like( $@, $match, 'join 6 (HASH reference for ON statement dies) ok' );
@@ -408,5 +408,9 @@
my $prefetch_result = make_hash_struc($art_rs_pr);
my $nonpre_result = make_hash_struc($art_rs);
+TODO: {
+ local $TODO = 'fixing collapse in -current';
is_deeply( $prefetch_result, $nonpre_result,
'Compare 2 level prefetch result to non-prefetch result' );
+}
+
Modified: branches/DBIx-Class/collapse_result_rewrite/t/92storage.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/92storage.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/92storage.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -4,12 +4,30 @@
use Test::More;
use lib qw(t/lib);
use DBICTest;
+use DBICTest::ExplodingStorage;
-plan tests => 1;
+plan tests => 3;
my $schema = DBICTest->init_schema();
is( ref($schema->storage), 'DBIx::Class::Storage::DBI::SQLite',
'Storage reblessed correctly into DBIx::Class::Storage::DBI::SQLite' );
+
+my $storage = $schema->storage;
+$storage->ensure_connected;
+
+bless $storage, "DBICTest::ExplodingStorage";
+$schema->storage($storage);
+
+eval {
+ $schema->resultset('Artist')->create({ name => "Exploding Sheep" })
+};
+
+is($@, "", "Exploding \$sth->execute was caught");
+
+is(1, $schema->resultset('Artist')->search({name => "Exploding Sheep" })->count,
+ "And the STH was retired");
+
+
1;
Modified: branches/DBIx-Class/collapse_result_rewrite/t/94versioning.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/94versioning.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/94versioning.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use File::Spec;
BEGIN {
eval "use DBD::SQLite; use SQL::Translator;";
@@ -23,7 +24,7 @@
my $schema_orig = DBICVersion::Schema->connect("dbi:SQLite:$db_file");
# $schema->storage->ensure_connected();
-is($schema_orig->ddl_filename('SQLite', 't/var', '1.0'), 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Filename creation working');
+is($schema_orig->ddl_filename('SQLite', 't/var', '1.0'), File::Spec->catfile('t', 'var', 'DBICVersion-Schema-1.0-SQLite.sql'), 'Filename creation working');
$schema_orig->create_ddl_dir('SQLite', undef, 't/var');
ok(-f 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Created DDL file');
Modified: branches/DBIx-Class/collapse_result_rewrite/t/96file_column.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/96file_column.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/96file_column.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -8,11 +8,8 @@
my $schema = DBICTest->init_schema();
-plan tests => 2;
+plan tests => 1;
-
-eval { $schema->resultset('FileColumn')->create({file=>'wrong set'}) };
-ok($@, 'FileColumn checking for checks against bad sets');
-my $fh = new IO::File('t/96file_column.pm','r');
-eval { $schema->resultset('FileColumn')->create({file => {handle => $fh, filename =>'96file_column.pm'}})};
+my $fh = new IO::File('t/96file_column.t','r');
+eval { $schema->resultset('FileColumn')->create({file => {handle => $fh, filename =>'96file_column.t'}})};
ok(!$@,'FileColumn checking if file handled properly.');
Modified: branches/DBIx-Class/collapse_result_rewrite/t/bindtype_columns.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/bindtype_columns.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/bindtype_columns.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -7,18 +7,14 @@
my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
-$dsn = 'dbi:Pg:dbname=postgres;host=localhost' unless $dsn;
-$dbuser = 'postgres' unless $dbuser;
-$dbpass = 'postgres' unless $dbpass;
-
plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
unless ($dsn && $dbuser);
plan tests => 3;
-DBICTest::Schema->compose_connection('PGTest' => $dsn, $dbuser, $dbpass);
+my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass);
-my $dbh = PGTest->schema->storage->dbh;
+my $dbh = $schema->storage->dbh;
$dbh->do(qq[
@@ -31,13 +27,13 @@
],{ RaiseError => 1, PrintError => 1 });
-PGTest::Artist->load_components(qw/
+$schema->class('Artist')->load_components(qw/
PK::Auto
Core
/);
-PGTest::Artist->add_columns(
+$schema->class('Artist')->add_columns(
"media", {
@@ -49,12 +45,12 @@
# test primary key handling
my $big_long_string = 'abcd' x 250000;
-my $new = PGTest::Artist->create({ media => $big_long_string });
+my $new = $schema->resultset('Artist')->create({ media => $big_long_string });
ok($new->artistid, "Created a blob row");
is($new->media, $big_long_string, "Set the blob correctly.");
-my $rs = PGTest::Artist->find({artistid=>$new->artistid});
+my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid});
is($rs->get_column('media'), $big_long_string, "Created the blob correctly.");
Modified: branches/DBIx-Class/collapse_result_rewrite/t/cdbi-t/09-has_many.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/cdbi-t/09-has_many.t 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/cdbi-t/09-has_many.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -6,15 +6,15 @@
eval "use DBIx::Class::CDBICompat;";
plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@;
eval "use DBD::SQLite";
- plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 30);
+ plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 31);
}
use lib 't/testlib';
use Film;
use Actor;
-Film->has_many(actors => Actor => 'Film', { order_by => 'name' });
Actor->has_a(Film => 'Film');
+Film->has_many(actors => 'Actor', { order_by => 'name' });
is(Actor->primary_column, 'id', "Actor primary OK");
ok(Actor->can('Salary'), "Actor table set-up OK");
@@ -110,3 +110,18 @@
is($as->Name, 'Arnold Schwarzenegger', "Arnie's still Arnie");
+
+# Test infering of the foreign key of a has_many from an existing has_a
+{
+ use Thing;
+ use OtherThing;
+
+ Thing->has_a(that_thing => "OtherThing");
+ OtherThing->has_many(things => "Thing");
+
+ my $other_thing = OtherThing->create({ id => 1 });
+ Thing->create({ id => 1, that_thing => $other_thing });
+ Thing->create({ id => 2, that_thing => $other_thing });
+
+ is_deeply [sort map { $_->id } $other_thing->things], [1,2];
+}
Added: branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/ExplodingStorage.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/ExplodingStorage.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/ExplodingStorage.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,28 @@
+package DBICTest::ExplodingStorage::Sth;
+
+sub execute {
+ die "Kablammo!";
+}
+
+sub bind_param {}
+
+package DBICTest::ExplodingStorage;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Storage::DBI::SQLite';
+
+my $count = 0;
+sub sth {
+ my ($self, $sql) = @_;
+ return bless {}, "DBICTest::ExplodingStorage::Sth" unless $count++;
+ return $self->next::method($sql);
+}
+
+sub connected {
+ return 0 if $count == 1;
+ return shift->next::method(@_);
+}
+
+1;
Modified: branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/Schema/FileColumn.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/Schema/FileColumn.pm 2007-05-10 21:29:55 UTC (rev 3282)
+++ branches/DBIx-Class/collapse_result_rewrite/t/lib/DBICTest/Schema/FileColumn.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -5,7 +5,7 @@
use warnings;
use base qw/DBIx::Class::Core/;
-__PACKAGE__->load_components(qw/FileColumn/);
+__PACKAGE__->load_components(qw/InflateColumn::File/);
__PACKAGE__->table('file_columns');
Added: branches/DBIx-Class/collapse_result_rewrite/t/resultset_class.t
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/resultset_class.t (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/t/resultset_class.t 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use Class::Inspector ();
+
+unshift(@INC, './t/lib');
+use lib 't/lib';
+plan tests => 5;
+
+use DBICTest;
+
+is(DBICTest::Schema->source('Artist')->resultset_class, 'DBIx::Class::ResultSet', 'default resultset class');
+ok(!Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded');
+DBICTest::Schema->source('Artist')->resultset_class('DBICNSTest::ResultSet::A');
+ok(Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class loaded automatically');
+is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICNSTest::ResultSet::A', 'custom resultset class set');
+
+my $schema = DBICTest->init_schema;
+my $resultset = $schema->resultset('Artist')->search;
+isa_ok($resultset, 'DBICNSTest::ResultSet::A', 'resultset is custom class');
Added: branches/DBIx-Class/collapse_result_rewrite/t/testlib/OtherThing.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/testlib/OtherThing.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/t/testlib/OtherThing.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,11 @@
+package OtherThing;
+use base 'DBIx::Class::Test::SQLite';
+
+OtherThing->set_table("other_thing");
+OtherThing->columns(All => qw(id));
+
+sub create_sql {
+ return qq{
+ id INTEGER
+ };
+}
Added: branches/DBIx-Class/collapse_result_rewrite/t/testlib/Thing.pm
===================================================================
--- branches/DBIx-Class/collapse_result_rewrite/t/testlib/Thing.pm (rev 0)
+++ branches/DBIx-Class/collapse_result_rewrite/t/testlib/Thing.pm 2007-05-10 21:30:41 UTC (rev 3283)
@@ -0,0 +1,14 @@
+package Thing;
+use base 'DBIx::Class::Test::SQLite';
+
+Thing->set_table("thing");
+Thing->columns(All => qw(id that_thing));
+
+sub create_sql {
+ return qq{
+ id INTEGER,
+ that_thing INTEGER
+ };
+}
+
+1;
More information about the Bast-commits
mailing list