From: Peter Rabbitson Date: Sun, 9 Aug 2009 13:22:09 +0000 (+0000) Subject: Merge 'trunk' into 'multicreate_fixes' X-Git-Tag: v0.08109~28^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3df4269ebcc71ebb69b00225f0a12762aa3e9b21;hp=d8a35ad60f5c359f6185854646392f194b393a48;p=dbsrgits%2FDBIx-Class.git Merge 'trunk' into 'multicreate_fixes' r7201@Thesaurus (orig r7198): caelum | 2009-08-04 22:18:27 +0200 update Changes r7208@Thesaurus (orig r7205): ribasushi | 2009-08-05 08:34:25 +0200 Bump dependencies: Test::More for the new no_plan/done_testing goodies File::Temp as per RT#48431 r7210@Thesaurus (orig r7207): ribasushi | 2009-08-05 08:36:32 +0200 r7156@Thesaurus (orig r7153): robkinyon | 2009-07-30 20:06:04 +0200 Create prefetch_redux branch r7164@Thesaurus (orig r7161): robkinyon | 2009-07-31 22:41:01 +0200 Added MooseX::Traits to Makefile.PL r7172@Thesaurus (orig r7169): robkinyon | 2009-08-03 05:49:59 +0200 Added two tests and marked one todo_skip r7187@Thesaurus (orig r7184): ribasushi | 2009-08-03 17:24:41 +0200 Use goto to preserve correct error-at-line reporting r7189@Thesaurus (orig r7186): ribasushi | 2009-08-04 12:34:58 +0200 Add an extra test specifically for distinct/prefetch Remove duplicate test in count/prefetch Switch to as_query instead of debug overloading r7190@Thesaurus (orig r7187): ribasushi | 2009-08-04 12:35:57 +0200 Fix how a distinct-induced group_by is calculated, taking in consideration the new prefetch mechanism r7197@Thesaurus (orig r7194): ribasushi | 2009-08-04 17:31:33 +0200 Traits not needed by anything currently in dbic r7198@Thesaurus (orig r7195): ribasushi | 2009-08-04 17:41:14 +0200 Move around tests a bit r7199@Thesaurus (orig r7196): mo | 2009-08-04 21:10:57 +0200 prefetch-grouped fails, again r7204@Thesaurus (orig r7201): ribasushi | 2009-08-04 22:50:51 +0200 Split the search_related prefetch tests into a standalone testfile r7205@Thesaurus (orig r7202): ribasushi | 2009-08-04 23:05:03 +0200 Move norbi's test to prefetch_redux - it's the same idea r7209@Thesaurus (orig r7206): ribasushi | 2009-08-05 08:35:48 +0200 Tadaaaa (even more prefetch insanity) r7212@Thesaurus (orig r7209): ribasushi | 2009-08-05 08:38:41 +0200 r7107@Thesaurus (orig r7104): caelum | 2009-07-24 06:51:57 +0200 new branch to move common mssql functionality into the base class, and other tweaks r7109@Thesaurus (orig r7106): caelum | 2009-07-24 07:28:11 +0200 moved code to ::DBI::MSSQL and added DT inflation test r7112@Thesaurus (orig r7109): caelum | 2009-07-24 08:46:16 +0200 merge in some more MSSQL code, including odbc dynamic cursor support r7113@Thesaurus (orig r7110): caelum | 2009-07-24 08:49:54 +0200 fix a warning in SQLAHacks r7114@Thesaurus (orig r7111): caelum | 2009-07-24 09:22:33 +0200 add placeholder support detection for mssql through dbd::sybase r7118@Thesaurus (orig r7115): caelum | 2009-07-24 16:39:06 +0200 minor doc clarification r7122@Thesaurus (orig r7119): caelum | 2009-07-25 16:10:30 +0200 move placeholder support detection into ::Sybase::Base r7123@Thesaurus (orig r7120): caelum | 2009-07-25 16:12:01 +0200 add a comment r7127@Thesaurus (orig r7124): caelum | 2009-07-26 18:04:29 +0200 SAVEPOINT methods for MSSQL r7140@Thesaurus (orig r7137): caelum | 2009-07-30 10:12:45 +0200 better tests for "smalldatetime" support in MSSQL r7142@Thesaurus (orig r7139): caelum | 2009-07-30 13:29:19 +0200 MSSQL GUID support r7147@Thesaurus (orig r7144): caelum | 2009-07-30 15:38:33 +0200 update sqlite test schema r7150@Thesaurus (orig r7147): caelum | 2009-07-30 16:26:47 +0200 make sure the new mssql insert method works on an un-reblessed storage r7151@Thesaurus (orig r7148): caelum | 2009-07-30 16:55:35 +0200 better rebless check for insert r7154@Thesaurus (orig r7151): caelum | 2009-07-30 18:57:22 +0200 add missing file r7155@Thesaurus (orig r7152): caelum | 2009-07-30 19:00:40 +0200 fix syntax error r7163@Thesaurus (orig r7160): caelum | 2009-07-31 15:52:41 +0200 fix a bug in _determine_driver r7166@Thesaurus (orig r7163): caelum | 2009-08-01 18:10:23 +0200 default collist for storage _resolve_column_info r7182@Thesaurus (orig r7179): caelum | 2009-08-03 13:42:31 +0200 check that dynamic cursors are functional if enabled r7184@Thesaurus (orig r7181): ribasushi | 2009-08-03 14:23:37 +0200 Adjust expected sql to match the new 'Track' table definition r7186@Thesaurus (orig r7183): ribasushi | 2009-08-03 15:16:10 +0200 Simplify code and add some comments r7200@Thesaurus (orig r7197): caelum | 2009-08-04 21:31:16 +0200 update oracle tests for new "track" table r7203@Thesaurus (orig r7200): caelum | 2009-08-04 22:39:57 +0200 update Changes r7214@Thesaurus (orig r7211): ribasushi | 2009-08-05 08:40:39 +0200 r7213@Thesaurus (orig r7210): ribasushi | 2009-08-05 08:40:20 +0200 Really sanify _resolve_column_info r7216@Thesaurus (orig r7213): ribasushi | 2009-08-05 10:19:37 +0200 Reminder about discard_changes and friends r7217@Thesaurus (orig r7214): ribasushi | 2009-08-05 10:26:20 +0200 Reformat and fill-in changes r7218@Thesaurus (orig r7215): caelum | 2009-08-05 10:37:12 +0200 rename connect_call_use_mars to connect_call_use_MARS r7219@Thesaurus (orig r7216): ribasushi | 2009-08-05 10:38:14 +0200 Silence a TODO test r7220@Thesaurus (orig r7217): caelum | 2009-08-05 10:46:11 +0200 minor Changes update r7230@Thesaurus (orig r7227): castaway | 2009-08-05 14:57:52 +0200 Minty's conversion of cookbook "arbitrary sql" to use ResultSource::View, plus some examples in ::View itself. Some style tweaks of mine r7231@Thesaurus (orig r7228): ribasushi | 2009-08-05 15:41:28 +0200 Dynamically load necessary table classes r7236@Thesaurus (orig r7233): caelum | 2009-08-05 19:49:51 +0200 fix rounding issues in mssql money tests r7237@Thesaurus (orig r7234): caelum | 2009-08-05 20:09:03 +0200 better money value comparison in tests r7239@Thesaurus (orig r7236): frew | 2009-08-05 20:53:32 +0200 whitespace jfklds;ajfklds;a r7240@Thesaurus (orig r7237): frew | 2009-08-05 20:54:41 +0200 Fix testing bug. Windows only. r7256@Thesaurus (orig r7253): ribasushi | 2009-08-07 11:19:35 +0200 r7232@Thesaurus (orig r7229): jnapiorkowski | 2009-08-05 16:56:32 +0200 added test for the new default force pool behavior in PK->discard_changes and cleaned up the related tests a bit to give more meaningful info r7233@Thesaurus (orig r7230): jnapiorkowski | 2009-08-05 16:57:45 +0200 opps typo in test status messages r7234@Thesaurus (orig r7231): jnapiorkowski | 2009-08-05 17:03:46 +0200 added the default attrs to solve the failing test recently commited r7235@Thesaurus (orig r7232): jnapiorkowski | 2009-08-05 17:58:44 +0200 added test to make sure you can override the default attributes to discard_changes r7241@Thesaurus (orig r7238): jnapiorkowski | 2009-08-05 22:00:58 +0200 added replication as an optional feature to make installing it easier r7253@Thesaurus (orig r7250): ribasushi | 2009-08-07 11:06:41 +0200 Streamline makefile dep handling r7254@Thesaurus (orig r7251): ribasushi | 2009-08-07 11:07:14 +0200 Switch to done_testing r7255@Thesaurus (orig r7252): ribasushi | 2009-08-07 11:19:13 +0200 Move discard_changes code to Row.pm, better docs r7257@Thesaurus (orig r7254): ribasushi | 2009-08-07 11:21:35 +0200 Remove merged branch r7259@Thesaurus (orig r7256): ribasushi | 2009-08-07 14:16:13 +0200 Fix bogus POD r7261@Thesaurus (orig r7258): ribasushi | 2009-08-07 17:22:58 +0200 per mst: no optional deps r7262@Thesaurus (orig r7259): ribasushi | 2009-08-08 17:02:39 +0200 Stop using discard_changes() in Ordered (if I knew it will be *that* complex I would not touch it) r7265@Thesaurus (orig r7262): ribasushi | 2009-08-08 17:49:19 +0200 r7032@Thesaurus (orig r7031): caelum | 2009-07-11 11:28:52 +0200 new branch to reduce connected() calls r7033@Thesaurus (orig r7032): caelum | 2009-07-11 13:07:41 +0200 added failing test r7034@Thesaurus (orig r7033): caelum | 2009-07-11 14:36:53 +0200 minor optimization r7048@Thesaurus (orig r7047): caelum | 2009-07-14 15:09:47 +0200 substantially reduced ping count, dynamic cursors support for mssql through odbc r7050@Thesaurus (orig r7049): caelum | 2009-07-14 16:06:39 +0200 a couple more options for odbc/mssql r7052@Thesaurus (orig r7051): caelum | 2009-07-15 00:14:09 +0200 unfuck ensure_connected for odbc/mssql r7055@Thesaurus (orig r7054): caelum | 2009-07-15 21:10:27 +0200 rename _scope_identity to _identity for odbc/mssql r7056@Thesaurus (orig r7055): caelum | 2009-07-16 00:41:45 +0200 add IC::DT tests for odbc/mssql r7069@Thesaurus (orig r7068): caelum | 2009-07-17 11:47:31 +0200 don't run connection actions if ->_rebless does not connect r7108@Thesaurus (orig r7105): caelum | 2009-07-24 07:26:13 +0200 moving test to another branch r7110@Thesaurus (orig r7107): caelum | 2009-07-24 07:52:33 +0200 revert odbc/mssql code to trunk and move it to another branch r7111@Thesaurus (orig r7108): caelum | 2009-07-24 08:13:35 +0200 revert t/746mssql.t to trunk and move to another branch r7224@Thesaurus (orig r7221): caelum | 2009-08-05 11:48:04 +0200 update branch after pull r7225@Thesaurus (orig r7222): ribasushi | 2009-08-05 12:09:07 +0200 Rename last_dbh and turn it into a public method r7226@Thesaurus (orig r7223): ribasushi | 2009-08-05 12:12:20 +0200 Whoopsie - more renames r7227@Thesaurus (orig r7224): ribasushi | 2009-08-05 12:32:09 +0200 Changes and a deploy() fix r7228@Thesaurus (orig r7225): ribasushi | 2009-08-05 12:36:01 +0200 We do not count pings during deploy - they are expected r7229@Thesaurus (orig r7226): ribasushi | 2009-08-05 12:49:06 +0200 Clarify autocommit default r7238@Thesaurus (orig r7235): caelum | 2009-08-05 20:39:47 +0200 fix up txn_begin and the ping_count test r7263@Thesaurus (orig r7260): ribasushi | 2009-08-08 17:40:19 +0200 A more straightforward txn_begin fix, some more test fixes r7270@Thesaurus (orig r7267): ribasushi | 2009-08-09 00:34:31 +0200 r6822@Thesaurus (orig r6821): caelum | 2009-06-28 14:38:12 +0200 branch r6825@Thesaurus (orig r6824): caelum | 2009-06-28 14:40:37 +0200 ->table(\"table") r6827@Thesaurus (orig r6826): caelum | 2009-06-28 14:55:06 +0200 revert r6829@Thesaurus (orig r6828): caelum | 2009-06-28 15:57:40 +0200 r5742@hlagh (orig r6819): ribasushi | 2009-06-28 04:00:03 -0700 The prefetch+group_by is a complex problem - branch r6834@Thesaurus (orig r6833): caelum | 2009-06-28 23:24:47 +0200 ->table(\"foo") now works r6835@Thesaurus (orig r6834): caelum | 2009-06-29 03:54:31 +0200 another test r6849@Thesaurus (orig r6848): caelum | 2009-06-29 21:39:26 +0200 separated table ref test out, changed CDTableRef to a view with less rels r6852@Thesaurus (orig r6851): caelum | 2009-06-29 22:56:45 +0200 changed CD to ->table(\"cd") r6853@Thesaurus (orig r6852): caelum | 2009-06-29 23:13:48 +0200 fix t/80unique.t r6857@Thesaurus (orig r6856): caelum | 2009-06-29 23:45:19 +0200 branch pushed, removing r6858@Thesaurus (orig r6857): caelum | 2009-06-29 23:46:54 +0200 removing debug statement r6860@Thesaurus (orig r6859): ribasushi | 2009-06-30 00:03:21 +0200 Minor fixes r6861@Thesaurus (orig r6860): ribasushi | 2009-06-30 00:25:27 +0200 This is sloppy, but sqlt is sloppy too. All tests pass now, all we really need is to intercept name() set-calls, and use a virtual view (the only legit setter is the new() call in ResultSourceProxy::Table r6867@Thesaurus (orig r6866): caelum | 2009-06-30 03:34:02 +0200 forgot to use Scalar::Util () r7007@Thesaurus (orig r7006): caelum | 2009-07-09 07:37:22 +0200 r5766@hlagh (orig r6843): abraxxa | 2009-06-29 02:02:17 -0700 fixed typo in test r5779@hlagh (orig r6847): ribasushi | 2009-06-29 10:09:00 -0700 Minor Ordered optimization (don't use count) r5787@hlagh (orig r6855): caelum | 2009-06-29 14:42:11 -0700 r5451@hlagh (orig r6605): caelum | 2009-06-10 09:23:44 -0700 new branch to implement on_connect_call r5484@hlagh (orig r6633): caelum | 2009-06-11 11:03:10 -0700 on_connect_call implementation and set_datetime_format support for Oracle r5492@hlagh (orig r6641): caelum | 2009-06-11 16:39:28 -0700 connect_call_set_datetime_format for Oracle, I have no idea why this didn't get committed before... r5504@hlagh (orig r6655): caelum | 2009-06-12 17:28:06 -0700 finished up on_connect_call stuff r5507@hlagh (orig r6658): caelum | 2009-06-13 04:03:36 -0700 fixup _setup_connect_do, other minor cleanups r5508@hlagh (orig r6659): caelum | 2009-06-13 04:35:33 -0700 make the on_(dis)?connect_do accessors returnn the original structure r5509@hlagh (orig r6660): caelum | 2009-06-13 08:31:52 -0700 allow undef for _setup_connect_do r5522@hlagh (orig r6679): caelum | 2009-06-14 09:56:40 -0700 rename connect_do store r5621@hlagh (orig r6769): caelum | 2009-06-23 07:38:33 -0700 minor doc update r5628@hlagh (orig r6777): caelum | 2009-06-23 16:36:12 -0700 properly test nanosecond precision with oracle and datetime_setup r5669@hlagh (orig r6784): caelum | 2009-06-24 10:49:25 -0700 IC::DT does support timestamp with timezone r5768@hlagh (orig r6846): caelum | 2009-06-29 08:20:32 -0700 remove DateTime from 73oracle.t r5781@hlagh (orig r6849): caelum | 2009-06-29 13:07:43 -0700 remove the _store stuff for on_connect_do r5785@hlagh (orig r6853): ribasushi | 2009-06-29 14:38:30 -0700 Some beautification r5802@hlagh (orig r6870): ribasushi | 2009-06-30 01:09:03 -0700 Cleanup dependency handling a bit r5806@hlagh (orig r6874): ribasushi | 2009-06-30 03:39:06 -0700 Allow broken resultsource-class-derived objects to still work r5807@hlagh (orig r6875): ribasushi | 2009-06-30 03:40:46 -0700 clarify r5835@hlagh (orig r6877): ash | 2009-06-30 04:48:13 -0700 Update POD on Dynamic sub-classing r5837@hlagh (orig r6882): ribasushi | 2009-06-30 08:36:38 -0700 r6815@Thesaurus (orig r6814): ribasushi | 2009-06-28 10:32:42 +0200 Branch to explore double joins on search_related r6816@Thesaurus (orig r6815): ribasushi | 2009-06-28 10:34:16 +0200 Thetest case that started it all r6817@Thesaurus (orig r6816): ribasushi | 2009-06-28 10:35:11 +0200 The proposed fix (do not add an extra join if it is already present in the topmost join) r6818@Thesaurus (orig r6817): ribasushi | 2009-06-28 11:04:26 +0200 Minor omission r6819@Thesaurus (orig r6818): ribasushi | 2009-06-28 11:07:33 +0200 Adjust a couple of tests for new behavior (thus all of this might be backwards incompatible to the point of being useless): The counts in t/90join_torture.t are now 5*3, not 5*3*3, as a second join is not induced by search_related The raw sql scan in t/prefetch/standard.t is just silly, won't even try to understand it Just to maintain the TreeLike folding, I add a 3rd children join which was inserted by search_related before the code changes r5843@hlagh (orig r6888): ribasushi | 2009-06-30 10:36:11 -0700 Todoify test for now r5844@hlagh (orig r6889): ribasushi | 2009-06-30 10:37:05 -0700 Todoify test for now (2) r5846@hlagh (orig r6891): ribasushi | 2009-06-30 10:52:31 -0700 Todoify test for now (3) r5850@hlagh (orig r6902): ribasushi | 2009-06-30 23:46:12 -0700 Fixed deadlock test r5851@hlagh (orig r6903): ribasushi | 2009-07-01 03:22:00 -0700 Clarify exception text r5854@hlagh (orig r6906): ribasushi | 2009-07-01 04:23:46 -0700 r6821@Thesaurus (orig r6820): ribasushi | 2009-06-28 13:09:11 +0200 Branch for prefetch+group play r6823@Thesaurus (orig r6822): ribasushi | 2009-06-28 14:38:36 +0200 Normalize group_by r6824@Thesaurus (orig r6823): ribasushi | 2009-06-28 14:39:54 +0200 Proper prefetch+group test r6826@Thesaurus (orig r6825): ribasushi | 2009-06-28 14:42:48 +0200 Whoops r6828@Thesaurus (orig r6827): ribasushi | 2009-06-28 15:06:57 +0200 Lose the literal sql bits - castaway is right it's silly to support those r6833@Thesaurus (orig r6832): ribasushi | 2009-06-28 22:38:43 +0200 Rogue comments r6837@Thesaurus (orig r6836): ribasushi | 2009-06-29 09:44:25 +0200 A couple of test fixes r6838@Thesaurus (orig r6837): ribasushi | 2009-06-29 09:46:13 +0200 Support for -select/-as in SQLAHacks field selection r6839@Thesaurus (orig r6838): ribasushi | 2009-06-29 09:49:53 +0200 This is tested elsewhere r6840@Thesaurus (orig r6839): ribasushi | 2009-06-29 09:50:43 +0200 This is tested elsewhere (2) r6841@Thesaurus (orig r6840): ribasushi | 2009-06-29 10:07:09 +0200 Test cleanups r6842@Thesaurus (orig r6841): ribasushi | 2009-06-29 10:11:13 +0200 Most of the grouped prefetch solution r6843@Thesaurus (orig r6842): ribasushi | 2009-06-29 10:14:45 +0200 clearer r6845@Thesaurus (orig r6844): ribasushi | 2009-06-29 12:05:37 +0200 And score! (all works) r6882@Thesaurus (orig r6881): ribasushi | 2009-06-30 16:23:06 +0200 rs->get_column now properly recognizes prefetch and collapses if at all possible r6886@Thesaurus (orig r6885): ribasushi | 2009-06-30 17:39:58 +0200 Whoops r5857@hlagh (orig r6909): ribasushi | 2009-07-01 04:27:15 -0700 Optimize set_column on uninserted objects r5867@hlagh (orig r6920): caelum | 2009-07-01 08:40:32 -0700 r5859@hlagh (orig r6912): caelum | 2009-07-01 06:21:30 -0700 new connected() for dbd::sybase users r5860@hlagh (orig r6913): caelum | 2009-07-01 06:25:46 -0700 add a couple of dbd::sybase reconnection tests r5861@hlagh (orig r6914): caelum | 2009-07-01 06:35:07 -0700 better connection test r5862@hlagh (orig r6915): caelum | 2009-07-01 06:45:05 -0700 use dbh->do for connected instead of prepare_cached r5863@hlagh (orig r6916): ribasushi | 2009-07-01 06:55:21 -0700 Segfault r5864@hlagh (orig r6917): caelum | 2009-07-01 07:03:22 -0700 use ->do instead of ->prepare_cached in oracle's connected() too r5865@hlagh (orig r6918): caelum | 2009-07-01 08:20:52 -0700 fix segfault with old DBD::Sybase r5866@hlagh (orig r6919): caelum | 2009-07-01 08:39:18 -0700 move connection tests into _ping() r5873@hlagh (orig r6923): ijw | 2009-07-01 10:34:32 -0700 Added a test for a resultset to related-resultset join for 0 related records r5874@hlagh (orig r6927): ijw | 2009-07-01 11:04:16 -0700 Additional tests on prefetch - illustrates the bug with left-join has_many (NULL row returned) and the one that results from the trivial fix (prefetch gives no artist) r5876@hlagh (orig r6931): ribasushi | 2009-07-01 23:08:33 -0700 Another candidate for somethingawful.com (fix left join-ed count) r5877@hlagh (orig r6933): ribasushi | 2009-07-02 00:04:13 -0700 Changelog r5878@hlagh (orig r6934): ribasushi | 2009-07-02 02:23:48 -0700 cleanup r5879@hlagh (orig r6935): ijw | 2009-07-02 03:41:01 -0700 Check fetched rows == count for related resultsets r5880@hlagh (orig r6936): ijw | 2009-07-02 03:43:47 -0700 Confirm prefetch doesn't affect main row fetch, and main row fetch works with and without counting r5881@hlagh (orig r6937): ribasushi | 2009-07-02 03:52:51 -0700 More fail (fix is known but needs work) r5882@hlagh (orig r6938): ribasushi | 2009-07-02 04:07:22 -0700 And more fail r5883@hlagh (orig r6939): ribasushi | 2009-07-02 04:16:46 -0700 These tests are in prefetch/count.t r5884@hlagh (orig r6940): ribasushi | 2009-07-02 04:38:31 -0700 cleanup r5885@hlagh (orig r6941): ribasushi | 2009-07-02 04:38:49 -0700 Solve more prefetch inflation crap r5886@hlagh (orig r6942): ribasushi | 2009-07-02 04:47:41 -0700 Make the code readable r5887@hlagh (orig r6943): ribasushi | 2009-07-02 06:52:35 -0700 Everything works, just need to fix join-path chaining over search_related (to guard against obscure db quirks) r5889@hlagh (orig r6945): caelum | 2009-07-02 12:06:32 -0700 add sybase reconnect test r5891@hlagh (orig r6947): ribasushi | 2009-07-02 13:20:21 -0700 Last part of the join handling puzzle r5894@hlagh (orig r6950): ribasushi | 2009-07-02 15:14:50 -0700 r6360@Thesaurus (orig r6359): arcanez | 2009-05-21 20:18:52 +0200 branch to work on prefetch/select r6361@Thesaurus (orig r6360): arcanez | 2009-05-21 20:32:46 +0200 failing test r6373@Thesaurus (orig r6372): ribasushi | 2009-05-22 11:07:26 +0200 Simplify unresolvable test by arcanez r6905@Thesaurus (orig r6904): ribasushi | 2009-07-01 12:54:03 +0200 Extend test r6950@Thesaurus (orig r6949): ribasushi | 2009-07-03 00:14:09 +0200 Apparent fix - simply delay the in_storage flagging of the main object until all prefetched objects are inflated. The rest of the changes are just cosmetics, preparing for the collapse_result rewrite r5896@hlagh (orig r6952): ribasushi | 2009-07-02 15:17:22 -0700 Changes r5909@hlagh (orig r6964): ribasushi | 2009-07-03 04:19:27 -0700 Add set_ansi_mode on_connect_call for mysql Also switch to _do_query instead of plain dbh->do (shows up in the trace) r5910@hlagh (orig r6965): ribasushi | 2009-07-03 04:37:06 -0700 Capitalize mysql commands r5911@hlagh (orig r6966): ribasushi | 2009-07-03 06:07:49 -0700 Double an existing might_have test as has_one r5912@hlagh (orig r6967): ribasushi | 2009-07-03 07:36:32 -0700 Extra test to demonstrate has_one working, and a POD clarification of multicreate r5917@hlagh (orig r6972): ribasushi | 2009-07-03 11:20:42 -0700 r6554@Thesaurus (orig r6553): frew | 2009-06-09 00:06:42 +0200 branch for mssql top issues r6572@Thesaurus (orig r6571): frew | 2009-06-09 23:18:46 +0200 more tests for SQL Server! r6573@Thesaurus (orig r6572): frew | 2009-06-09 23:49:10 +0200 Added AmbiguousGlob.pm for silly servers like mssql and mysql. See docs for more info r6574@Thesaurus (orig r6573): frew | 2009-06-09 23:55:22 +0200 fix plan r6602@Thesaurus (orig r6601): frew | 2009-06-10 17:03:30 +0200 more failing tests r6608@Thesaurus (orig r6607): frew | 2009-06-10 20:05:53 +0200 don't use eval! r6610@Thesaurus (orig r6609): frew | 2009-06-10 20:07:49 +0200 beginning of DWIM for IDENTITY_INSERT r6628@Thesaurus (orig r6627): frew | 2009-06-11 18:13:02 +0200 still busted :-( r6631@Thesaurus (orig r6630): frew | 2009-06-11 19:39:00 +0200 general function to go from column names and ident to result source r6632@Thesaurus (orig r6631): frew | 2009-06-11 19:40:11 +0200 Use new _resolve_column_sources method and begin insert_bulk method r6635@Thesaurus (orig r6634): frew | 2009-06-11 20:12:38 +0200 updated _resolve_column_source to _resolve_column_info as per ribasushi's suggestion r6650@Thesaurus (orig r6649): frew | 2009-06-12 17:13:32 +0200 Now I just need to check if the actual values are set... r6651@Thesaurus (orig r6650): frew | 2009-06-12 17:26:53 +0200 Insert Identity works! r6652@Thesaurus (orig r6651): frew | 2009-06-12 17:34:13 +0200 silly warns. r6684@Thesaurus (orig r6683): frew | 2009-06-15 16:49:00 +0200 failing test r6686@Thesaurus (orig r6685): ribasushi | 2009-06-15 18:10:26 +0200 make all resolved attrs visible to sqla r6698@Thesaurus (orig r6697): ribasushi | 2009-06-17 02:31:37 +0200 Half way working stuff, needs a LOT of tweaking still r6729@Thesaurus (orig r6728): ribasushi | 2009-06-19 19:49:27 +0200 Merge badness r6730@Thesaurus (orig r6729): ribasushi | 2009-06-19 19:49:40 +0200 fix eol r6731@Thesaurus (orig r6730): ribasushi | 2009-06-19 19:55:47 +0200 augment inheritance r6735@Thesaurus (orig r6734): ribasushi | 2009-06-20 10:34:42 +0200 Maybe I've nailed it r6746@Thesaurus (orig r6745): ribasushi | 2009-06-20 23:53:55 +0200 Test and merge fixes r6747@Thesaurus (orig r6746): ribasushi | 2009-06-21 00:01:09 +0200 Really fix tests r6748@Thesaurus (orig r6747): ribasushi | 2009-06-21 00:01:54 +0200 Really fix tests r6749@Thesaurus (orig r6748): ribasushi | 2009-06-21 00:18:33 +0200 Now really final r6750@Thesaurus (orig r6749): ribasushi | 2009-06-21 00:22:23 +0200 whoops r6751@Thesaurus (orig r6750): ribasushi | 2009-06-21 00:42:18 +0200 That should be all r6752@Thesaurus (orig r6751): ribasushi | 2009-06-21 08:54:00 +0200 Make sure quoting works r6755@Thesaurus (orig r6754): ribasushi | 2009-06-21 15:21:23 +0200 Groundwork for sanification of the toplimit test r6863@Thesaurus (orig r6862): ribasushi | 2009-06-30 01:13:49 +0200 Make sure storage classes use c3, just like the rest of dbic (tested on 5.8 as well) r6869@Thesaurus (orig r6868): ribasushi | 2009-06-30 09:53:27 +0200 Some fixes after review r6874@Thesaurus (orig r6873): ribasushi | 2009-06-30 11:54:34 +0200 Fix borked next invocation r6896@Thesaurus (orig r6895): frew | 2009-06-30 21:38:26 +0200 silly misspells and trailing whitespace r6955@Thesaurus (orig r6954): ribasushi | 2009-07-03 01:21:28 +0200 Some hack consolidation r6962@Thesaurus (orig r6961): ribasushi | 2009-07-03 12:06:57 +0200 Fix some mssql shortcommings when confronted with the new subequeried prefetch sql r6963@Thesaurus (orig r6962): ribasushi | 2009-07-03 12:47:57 +0200 Ask for newer DBD::Pg in author mode, suggest the newer version otherwise (proper array support). Make test more resilient as well r6964@Thesaurus (orig r6963): ribasushi | 2009-07-03 12:49:16 +0200 Switch to C3 mro throughout the ::Storage hierarchy (DBIx::Class brings in MRO::Compat, and all ::Storage's are based on it, tested on 5.8 r6969@Thesaurus (orig r6968): ribasushi | 2009-07-03 19:54:04 +0200 Duh r6970@Thesaurus (orig r6969): frew | 2009-07-03 19:59:48 +0200 fix tests for new codez r6971@Thesaurus (orig r6970): ribasushi | 2009-07-03 20:18:53 +0200 detabify r6972@Thesaurus (orig r6971): ribasushi | 2009-07-03 20:20:07 +0200 changes r5920@hlagh (orig r6979): ribasushi | 2009-07-04 02:34:08 -0700 Hide devel documentation from the indexer r5921@hlagh (orig r6980): ribasushi | 2009-07-04 02:37:25 -0700 Add set_ansi_mode POD r5922@hlagh (orig r6981): ribasushi | 2009-07-04 02:45:24 -0700 Backout mysql changes for further polishing r5925@hlagh (orig r6984): ribasushi | 2009-07-04 03:08:16 -0700 Missing newline r5926@hlagh (orig r6985): ribasushi | 2009-07-04 03:11:18 -0700 typo r5927@hlagh (orig r6986): ribasushi | 2009-07-04 03:40:47 -0700 Fix POD r5928@hlagh (orig r6987): ribasushi | 2009-07-04 04:09:39 -0700 todos are shorter now r5929@hlagh (orig r6989): castaway | 2009-07-05 13:00:55 -0700 Added Pod::Inherit use to Makefile.PL at author-time, comments/suggestions as to whether its too "noisy" welcome. r5930@hlagh (orig r6990): ribasushi | 2009-07-05 15:06:52 -0700 Couple of makefile fixes: use is compile time, use require recommends is for distro maintainers only, push the dependency into the authors hash (it is not to be executed by mere mortals) r5931@hlagh (orig r6991): ribasushi | 2009-07-05 15:55:36 -0700 Forgotten pod exclusions r5932@hlagh (orig r6992): ribasushi | 2009-07-05 16:07:05 -0700 Temporarily backout Pod::Inherit changes r5933@hlagh (orig r6993): ribasushi | 2009-07-05 16:10:22 -0700 Put Pod::Inherit stuff back after proper copy r7027@Thesaurus (orig r7026): caelum | 2009-07-10 23:25:56 +0200 r5941@hlagh (orig r7009): ribasushi | 2009-07-09 03:45:02 -0700 r6995@Thesaurus (orig r6994): ribasushi | 2009-07-06 01:12:57 +0200 Where 08108 will come from r7029@Thesaurus (orig r7028): caelum | 2009-07-10 23:59:31 +0200 r5959@hlagh (orig r7027): caelum | 2009-07-10 14:56:57 -0700 fix PodInherit call in Makefile.PL r7067@Thesaurus (orig r7066): caelum | 2009-07-17 10:18:24 +0200 r5961@hlagh (orig r7029): robkinyon | 2009-07-10 18:03:07 -0400 Applied patch from kados regarding use of a DateTime::Format class to validate r5962@hlagh (orig r7030): caelum | 2009-07-11 05:26:40 -0400 reword IC::DT doc patch r6009@hlagh (orig r7037): dandv | 2009-07-13 08:06:08 -0400 PK::Auto has moved into Core since 2007 r6010@hlagh (orig r7038): dandv | 2009-07-13 08:15:13 -0400 Fixed has_many example in Intro.pod r6011@hlagh (orig r7039): dandv | 2009-07-13 16:58:45 -0400 Fixed run-on sentences in FAQ r6012@hlagh (orig r7040): dandv | 2009-07-13 17:18:11 -0400 Minor POD fixes in Example.pod r6013@hlagh (orig r7041): dandv | 2009-07-13 17:48:18 -0400 Favored using ->single to get the topmost result over less readable ->slice(0) r6014@hlagh (orig r7042): dandv | 2009-07-13 18:56:31 -0400 Minor POD fixes in Cookbook r6015@hlagh (orig r7045): ribasushi | 2009-07-14 07:30:55 -0400 Minor logic cleanup r6016@hlagh (orig r7046): ribasushi | 2009-07-14 08:07:11 -0400 grouped prefetch fix r6023@hlagh (orig r7053): ijw | 2009-07-15 12:55:35 -0400 Added SQLA link for more comprehensive documentation of order_by options available r6026@hlagh (orig r7056): caelum | 2009-07-15 18:54:22 -0400 add "smalldatetime" support to IC::DT r6029@hlagh (orig r7059): ribasushi | 2009-07-16 00:29:41 -0400 r7013@Thesaurus (orig r7012): jnapiorkowski | 2009-07-09 17:00:22 +0200 new branch r7014@Thesaurus (orig r7013): jnapiorkowski | 2009-07-09 20:06:44 +0200 changed the way transactions are detected for replication to work with the standard way to do this, minor doc updates, fix to the force pool so you can force a particular slave, changes to the way the debugging is created r7015@Thesaurus (orig r7014): jnapiorkowski | 2009-07-09 20:17:03 +0200 more changes to the way debug output works r7016@Thesaurus (orig r7015): jnapiorkowski | 2009-07-09 22:26:47 +0200 big update to the test suite so that we now check to make sure the storage that was expected was actually used r7017@Thesaurus (orig r7016): jnapiorkowski | 2009-07-09 23:23:37 +0200 set correct number of tests, changed the debuggin output to not warn on DDL, minor change to a test resultclass so we can deploy to mysql properly r7018@Thesaurus (orig r7017): jnapiorkowski | 2009-07-09 23:26:59 +0200 corrected the number of skipped tests r7019@Thesaurus (orig r7018): jnapiorkowski | 2009-07-09 23:52:22 +0200 fixed test resultclass formatting, added a few more DBIC::Storage::DBI methods that I might need to delegate. r7020@Thesaurus (orig r7019): jnapiorkowski | 2009-07-10 01:23:07 +0200 some documention updates and changed the way we find paths for the sqlite dbfiles to use File::Spec, which I hope will solve some of the Win32 error messages r7023@Thesaurus (orig r7022): jnapiorkowski | 2009-07-10 18:00:38 +0200 pod cleanup, fixed broken pod links, and new Introduction pod r7024@Thesaurus (orig r7023): jnapiorkowski | 2009-07-10 19:10:57 +0200 updated Changes file to reflect work completed r7025@Thesaurus (orig r7024): jnapiorkowski | 2009-07-10 19:37:53 +0200 a few more Moose Type related fixes and added diag to the replication test to report the moose and types version used, to help us debug some of the moose related errors being reported r7058@Thesaurus (orig r7057): ribasushi | 2009-07-16 06:28:44 +0200 A couple of typos, and general whitespace cleanup (ick) r6031@hlagh (orig r7062): jnapiorkowski | 2009-07-16 11:03:32 -0400 increased Moose version requirements due to changes in the way type constraints get validated, which is not backwardly compatible r6032@hlagh (orig r7063): dandv | 2009-07-16 21:37:28 -0400 Minor POD grammar: it's -> its where appropriate r7105@Thesaurus (orig r7102): caelum | 2009-07-24 06:34:56 +0200 r6075@hlagh (orig r7074): tomboh | 2009-07-20 12:20:37 -0400 Fix POD changes from r7040. r6081@hlagh (orig r7077): norbi | 2009-07-20 18:59:30 -0400 r6082@hlagh (orig r7078): norbi | 2009-07-20 18:59:58 -0400 r7232@vger: mendel | 2009-07-21 00:58:12 +0200 Fixed documentation and added test for the "Arbitrary SQL through a custom ResultSource" Cookbook alternate (subclassing) recipe. r6083@hlagh (orig r7079): norbi | 2009-07-20 19:05:32 -0400 r7235@vger: mendel | 2009-07-21 01:05:18 +0200 Fixed 'typo' (removed a word that I left there by accident). r6084@hlagh (orig r7080): norbi | 2009-07-21 04:06:21 -0400 r7237@vger: mendel | 2009-07-21 10:06:05 +0200 Fixing what my svk client screwed up. r6085@hlagh (orig r7081): caelum | 2009-07-21 10:51:55 -0400 update Storage::Replicated prereqs r6086@hlagh (orig r7082): caelum | 2009-07-21 12:16:34 -0400 show Oracle datetime_setup alter session statements in debug output r6088@hlagh (orig r7085): ribasushi | 2009-07-21 21:50:57 -0400 Lazy folks do not run the whole test suite before merging >:( r6287@hlagh (orig r7097): caelum | 2009-07-23 14:14:11 -0400 r6092@hlagh (orig r7090): caelum | 2009-07-23 08:24:39 -0400 new branch for fixing the MONEY type in MSSQL r6093@hlagh (orig r7091): caelum | 2009-07-23 08:34:01 -0400 add test r6283@hlagh (orig r7093): caelum | 2009-07-23 10:31:08 -0400 fix money columns r6284@hlagh (orig r7094): caelum | 2009-07-23 10:34:06 -0400 minor change r6285@hlagh (orig r7095): caelum | 2009-07-23 11:01:37 -0400 add test for updating money value to NULL r6286@hlagh (orig r7096): caelum | 2009-07-23 14:09:26 -0400 add money type tests to dbd::sybase+mssql tests r7135@Thesaurus (orig r7132): caelum | 2009-07-28 19:10:40 +0200 r6365@hlagh (orig r7126): caelum | 2009-07-27 20:03:47 -0400 add postgres "timestamp without time zone" support r7244@Thesaurus (orig r7241): caelum | 2009-08-06 17:12:49 +0200 add warning for custom resultsources through ->name(SCALARREF) on ->deploy r7245@Thesaurus (orig r7242): caelum | 2009-08-06 17:54:33 +0200 improve the ->name(REF) warning code r7268@Thesaurus (orig r7265): ribasushi | 2009-08-09 00:23:24 +0200 Clarify POD and cleanup the ->name-hack warning r7269@Thesaurus (orig r7266): ribasushi | 2009-08-09 00:34:09 +0200 Fix a corner case and improve comments --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index f3c4b4f..dfa4c78 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1265,18 +1265,22 @@ sub pk_depends_on { # hashref of columns of the related object. sub _pk_depends_on { my ($self, $relname, $rel_data) = @_; - my $cond = $self->relationship_info($relname)->{cond}; + my $relinfo = $self->relationship_info($relname); + + # don't assume things if the relationship direction is specified + return $relinfo->{attrs}{is_foreign_key_constraint} + if exists ($relinfo->{attrs}{is_foreign_key_constraint}); + + my $cond = $relinfo->{cond}; return 0 unless ref($cond) eq 'HASH'; # map { foreign.foo => 'self.bar' } to { bar => 'foo' } - my $keyhash = { map { my $x = $_; $x =~ s/.*\.//; $x; } reverse %$cond }; # assume anything that references our PK probably is dependent on us # rather than vice versa, unless the far side is (a) defined or (b) # auto-increment - my $rel_source = $self->related_source($relname); foreach my $p ($self->primary_columns) { diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 158c215..89f1de3 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -164,8 +164,6 @@ sub new { unless ref($attrs) eq 'HASH'; my ($related,$inflated); - ## Pretend all the rels are actual objects, unset below if not, for insert() to fix - $new->{_rel_in_storage} = 1; foreach my $key (keys %$attrs) { if (ref $attrs->{$key}) { @@ -181,9 +179,9 @@ sub new { } if ($rel_obj->in_storage) { + $new->{_rel_in_storage}{$key} = 1; $new->set_from_related($key, $rel_obj); } else { - $new->{_rel_in_storage} = 0; MULTICREATE_DEBUG and warn "MC $new uninserted $key $rel_obj\n"; } @@ -202,13 +200,11 @@ sub new { } if ($rel_obj->in_storage) { - $new->set_from_related($key, $rel_obj); + $rel_obj->throw_exception ('A multi relationship can not be pre-existing when doing multicreate. Something went wrong'); } else { - $new->{_rel_in_storage} = 0; MULTICREATE_DEBUG and warn "MC $new uninserted $key $rel_obj (${\($idx+1)} of $total)\n"; } - $new->set_from_related($key, $rel_obj) if $rel_obj->in_storage; push(@objects, $rel_obj); } $related->{$key} = \@objects; @@ -221,8 +217,10 @@ sub new { if(!Scalar::Util::blessed($rel_obj)) { $rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj); } - unless ($rel_obj->in_storage) { - $new->{_rel_in_storage} = 0; + if ($rel_obj->in_storage) { + $new->{_rel_in_storage}{$key} = 1; + } + else { MULTICREATE_DEBUG and warn "MC $new uninserted $key $rel_obj"; } $inflated->{$key} = $rel_obj; @@ -286,27 +284,21 @@ sub insert { my %related_stuff = (%{$self->{_relationship_data} || {}}, %{$self->{_inflated_column} || {}}); - if(!$self->{_rel_in_storage}) { - - # The guard will save us if we blow out of this scope via die - $rollback_guard = $source->storage->txn_scope_guard; - - ## Should all be in relationship_data, but we need to get rid of the - ## 'filter' reltype.. - ## These are the FK rels, need their IDs for the insert. - - my @pri = $self->primary_columns; + # insert what needs to be inserted before us + my %pre_insert; + for my $relname (keys %related_stuff) { + my $rel_obj = $related_stuff{$relname}; - REL: foreach my $relname (keys %related_stuff) { + if (! $self->{_rel_in_storage}{$relname}) { + next unless (Scalar::Util::blessed($rel_obj) + && $rel_obj->isa('DBIx::Class::Row')); - my $rel_obj = $related_stuff{$relname}; + next unless $source->_pk_depends_on( + $relname, { $rel_obj->get_columns } + ); - next REL unless (Scalar::Util::blessed($rel_obj) - && $rel_obj->isa('DBIx::Class::Row')); - - next REL unless $source->_pk_depends_on( - $relname, { $rel_obj->get_columns } - ); + # The guard will save us if we blow out of this scope via die + $rollback_guard ||= $source->storage->txn_scope_guard; MULTICREATE_DEBUG and warn "MC $self pre-reconstructing $relname $rel_obj\n"; @@ -315,10 +307,19 @@ sub insert { ->related_source($relname) ->resultset ->find_or_create($them); + %{$rel_obj} = %{$re}; - $self->set_from_related($relname, $rel_obj); - delete $related_stuff{$relname}; + $self->{_rel_in_storage}{$relname} = 1; } + + $self->set_from_related($relname, $rel_obj); + delete $related_stuff{$relname}; + } + + # start a transaction here if not started yet and there is more stuff + # to insert after us + if (keys %related_stuff) { + $rollback_guard ||= $source->storage->txn_scope_guard } MULTICREATE_DEBUG and do { @@ -332,13 +333,12 @@ sub insert { ## PK::Auto my @auto_pri = grep { - !defined $self->get_column($_) || - ref($self->get_column($_)) eq 'SCALAR' + (not defined $self->get_column($_)) + || + (ref($self->get_column($_)) eq 'SCALAR') } $self->primary_columns; if (@auto_pri) { - #$self->throw_exception( "More than one possible key found for auto-inc on ".ref $self ) - # if defined $too_many; MULTICREATE_DEBUG and warn "MC $self fetching missing PKs ".join(', ', @auto_pri)."\n"; my $storage = $self->result_source->storage; $self->throw_exception( "Missing primary key but Storage doesn't support last_insert_id" ) @@ -353,47 +353,48 @@ sub insert { $self->{_dirty_columns} = {}; $self->{related_resultsets} = {}; - if(!$self->{_rel_in_storage}) { - ## Now do the relationships that need our ID (has_many etc.) - foreach my $relname (keys %related_stuff) { - my $rel_obj = $related_stuff{$relname}; - my @cands; - if (Scalar::Util::blessed($rel_obj) - && $rel_obj->isa('DBIx::Class::Row')) { - @cands = ($rel_obj); - } elsif (ref $rel_obj eq 'ARRAY') { - @cands = @$rel_obj; - } - if (@cands) { - my $reverse = $source->reverse_relationship_info($relname); - foreach my $obj (@cands) { - $obj->set_from_related($_, $self) for keys %$reverse; - my $them = { %{$obj->{_relationship_data} || {} }, $obj->get_inflated_columns }; - if ($self->__their_pk_needs_us($relname, $them)) { - if (exists $self->{_ignore_at_insert}{$relname}) { - MULTICREATE_DEBUG and warn "MC $self skipping post-insert on $relname"; - } else { - MULTICREATE_DEBUG and warn "MC $self re-creating $relname $obj"; - my $re = $self->result_source - ->related_source($relname) - ->resultset - ->find_or_create($them); - %{$obj} = %{$re}; - MULTICREATE_DEBUG and warn "MC $self new $relname $obj"; - } + foreach my $relname (keys %related_stuff) { + my $rel_obj = $related_stuff{$relname}; + my @cands; + if (Scalar::Util::blessed($rel_obj) + && $rel_obj->isa('DBIx::Class::Row')) + { + @cands = ($rel_obj); + } + elsif (ref $rel_obj eq 'ARRAY') { + @cands = @$rel_obj; + } + + if (@cands) { + my $reverse = $source->reverse_relationship_info($relname); + foreach my $obj (@cands) { + $obj->set_from_related($_, $self) for keys %$reverse; + my $them = { %{$obj->{_relationship_data} || {} }, $obj->get_inflated_columns }; + if ($self->__their_pk_needs_us($relname, $them)) { + if (exists $self->{_ignore_at_insert}{$relname}) { + MULTICREATE_DEBUG and warn "MC $self skipping post-insert on $relname"; } else { - MULTICREATE_DEBUG and warn "MC $self post-inserting $obj"; - $obj->insert(); + MULTICREATE_DEBUG and warn "MC $self re-creating $relname $obj"; + my $re = $self->result_source + ->related_source($relname) + ->resultset + ->create($them); + %{$obj} = %{$re}; + MULTICREATE_DEBUG and warn "MC $self new $relname $obj"; } + } else { + MULTICREATE_DEBUG and warn "MC $self post-inserting $obj"; + $obj->insert(); } } } - delete $self->{_ignore_at_insert}; - $rollback_guard->commit; } $self->in_storage(1); - undef $self->{_orig_ident}; + delete $self->{_orig_ident}; + delete $self->{_ignore_at_insert}; + $rollback_guard->commit if $rollback_guard; + return $self; } diff --git a/t/multi_create/diamond.t b/t/multi_create/diamond.t new file mode 100644 index 0000000..499f7a1 --- /dev/null +++ b/t/multi_create/diamond.t @@ -0,0 +1,52 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} }; + +my $schema = DBICTest->init_schema(); + +mc_diag (<<'DG'); +* Try a diamond multicreate + +Artist -> has_many -> Artwork_to_Artist -> belongs_to + / + belongs_to <- CD <- belongs_to <- Artwork <-/ + \ + \-> Artist2 + +DG + +lives_ok (sub { + $schema->resultset ('Artist')->create ({ + name => 'The wooled wolf', + artwork_to_artist => [{ + artwork => { + cd => { + title => 'Wool explosive', + year => 1999, + artist => { name => 'The black exploding sheep' }, + } + } + }], + }); + + my $art2 = $schema->resultset ('Artist')->find ({ name => 'The black exploding sheep' }); + ok ($art2, 'Second artist exists'); + + my $cd = $art2->cds->single; + is ($cd->title, 'Wool explosive', 'correctly created CD'); + + is_deeply ( + [ $cd->artwork->artists->get_column ('name')->all ], + [ 'The wooled wolf' ], + 'Artist correctly attached to artwork', + ); + +}, 'Diamond chain creation ok'); + +done_testing; diff --git a/t/multi_create/existing_in_chain.t b/t/multi_create/existing_in_chain.t new file mode 100644 index 0000000..c4464a8 --- /dev/null +++ b/t/multi_create/existing_in_chain.t @@ -0,0 +1,84 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +plan 'no_plan'; + +my $schema = DBICTest->init_schema(); + +{ + my $counts; + $counts->{$_} = $schema->resultset($_)->count for qw/Track CD Genre/; + + lives_ok (sub { + my $existing_nogen_cd = $schema->resultset('CD')->search ( + { 'genre.genreid' => undef }, + { join => 'genre' }, + )->first; + + $schema->resultset('Track')->create ({ + title => 'Sugar-coated', + cd => { + title => $existing_nogen_cd->title, + genre => { + name => 'sugar genre', + } + } + }); + + is ($schema->resultset('Track')->count, $counts->{Track} + 1, '1 new track'); + is ($schema->resultset('CD')->count, $counts->{CD}, 'No new cds'); + is ($schema->resultset('Genre')->count, $counts->{Genre} + 1, '1 new genre'); + + is ($existing_nogen_cd->genre->title, 'sugar genre', 'Correct genre assigned to CD'); + }); +} + +{ + my $counts; + $counts->{$_} = $schema->resultset($_)->count for qw/Artist CD Producer/; + + lives_ok (sub { + my $artist = $schema->resultset('Artist')->first; + my $producer = $schema->resultset('Producer')->create ({ name => 'the queen of england' }); + + $schema->resultset('CD')->create ({ + artist => $artist, + title => 'queen1', + year => 2007, + cd_to_producer => [ + { + producer => { + name => $producer->name, + producer_to_cd => [ + { + cd => { + title => 'queen2', + year => 2008, + artist => $artist, + }, + }, + ], + }, + }, + ], + }); + + is ($schema->resultset('Artist')->count, $counts->{Artist}, 'No new artists'); + is ($schema->resultset('Producer')->count, $counts->{Producer} + 1, '1 new producers'); + is ($schema->resultset('CD')->count, $counts->{CD} + 2, '2 new cds'); + + is ($producer->cds->count, 2, 'CDs assigned to correct producer'); + is_deeply ( + [ $producer->cds->search ({}, { order_by => 'title' })->get_column('title')->all], + [ qw/queen1 queen2/ ], + 'Correct cd names', + ); + }); +} + +1; diff --git a/t/multi_create/has_many.t b/t/multi_create/has_many.t new file mode 100644 index 0000000..2d6818e --- /dev/null +++ b/t/multi_create/has_many.t @@ -0,0 +1,33 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +plan tests => 2; + +my $schema = DBICTest->init_schema(); + +my $track_no_lyrics = $schema->resultset ('Track') + ->search ({ 'lyrics.lyric_id' => undef }, { join => 'lyrics' }) + ->first; + +my $lyric = $track_no_lyrics->create_related ('lyrics', { + lyric_versions => [ + { text => 'english doubled' }, + { text => 'english doubled' }, + ], +}); +is ($lyric->lyric_versions->count, 2, "Two identical has_many's created"); + + +my $link = $schema->resultset ('Link')->create ({ + url => 'lolcats!', + bookmarks => [ + {}, + {}, + ] +}); +is ($link->bookmarks->count, 2, "Two identical default-insert has_many's created"); diff --git a/t/multi_create/multilev_single_PKeqFK.t b/t/multi_create/multilev_single_PKeqFK.t index 07101a2..255f6cf 100644 --- a/t/multi_create/multilev_single_PKeqFK.t +++ b/t/multi_create/multilev_single_PKeqFK.t @@ -8,8 +8,6 @@ use DBICTest; sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} }; -plan tests => 26; - my $schema = DBICTest->init_schema(); mc_diag (<<'DG'); @@ -102,4 +100,4 @@ for my $type (qw/has_one might_have/) { }, "multilevel $type with a PK == FK in the $type/has_many table ok"); } -1; +done_testing; \ No newline at end of file diff --git a/t/multi_create/standard.t b/t/multi_create/standard.t index 9cd754f..57993cf 100644 --- a/t/multi_create/standard.t +++ b/t/multi_create/standard.t @@ -6,7 +6,7 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 93; +plan tests => 91; my $schema = DBICTest->init_schema(); @@ -329,26 +329,6 @@ lives_ok ( sub { }, 'Nested find_or_create'); lives_ok ( sub { - my $artist2 = $schema->resultset('Artist')->create({ - name => 'Fred 4', - cds => [ - { - title => 'Music to code by', - year => 2007, - }, - ], - cds_unordered => [ - { - title => 'Music to code by', - year => 2007, - }, - ] - }); - - is($artist2->in_storage, 1, 'artist with duplicate rels inserted okay'); -}, 'Multiple same level has_many create'); - -lives_ok ( sub { my $artist = $schema->resultset('Artist')->first; my $cd_result = $artist->create_related('cds', {