Merge 'DBIx-Class-current' into 'many_to_many'
Aran Deltac [Mon, 29 May 2006 07:23:49 +0000 (07:23 +0000)]
r1716@moss (orig r1715):  matthewt | 2006-05-19 17:34:58 -0700
 r8698@cain (orig r1666):  tomk | 2006-05-18 15:56:54 +0000
 Moved UUIDColumns.pm over from main DBIx::Class dist

 r8699@cain (orig r1667):  tomk | 2006-05-18 15:59:52 +0000
 Moved UUIDMaker.pm over from main DBIx::Class dist

 r8707@cain (orig r1675):  tomk | 2006-05-18 16:49:41 +0000
 Undoing changes commited in revisions 1664-1671... Sorry for the fuck up
 r8718@cain (orig r1681):  jguenther | 2006-05-18 18:32:06 +0000
 added bind information to exception thrown from DBIx::Class::Storage::DBI::_execute()
 r8731@cain (orig r1684):  jguenther | 2006-05-18 21:55:45 +0000
 removed another couple extraneous $self->dbh calls
 r8732@cain (orig r1685):  jguenther | 2006-05-18 22:11:20 +0000
 fixed small error in the SYNOPSIS of ResultSetManager.pm
 r8733@cain (orig r1686):  jguenther | 2006-05-18 22:34:31 +0000
 fixed an out-of-date limitation for has_many prefetch mentioned in Cookbook.pm
 r8741@cain (orig r1694):  castaway | 2006-05-19 12:42:20 +0000
 Update VERSION

 r8742@cain (orig r1695):  castaway | 2006-05-19 13:03:20 +0000
 Oops, fix bookmark thingy here too

 r8743@cain (orig r1696):  castaway | 2006-05-19 13:12:22 +0000
 .. And correct the number of tests

r1719@moss (orig r1718):  matthewt | 2006-05-19 17:53:52 -0700
 r1656@cain (orig r1519):  matthewt | 2006-04-26 03:19:25 +0000
 Added InflateColumn::DateTime component

r1720@moss (orig r1719):  matthewt | 2006-05-19 17:54:25 -0700
 r8669@cain (orig r1643):  matthewt | 2006-05-17 00:22:06 +0000
 Missing stuff for DateTime branch

r1721@moss (orig r1720):  matthewt | 2006-05-19 17:54:29 -0700

r1722@moss (orig r1721):  matthewt | 2006-05-19 17:54:33 -0700

r1723@moss (orig r1722):  matthewt | 2006-05-19 17:54:37 -0700
 r8762@cain (orig r1713):  matthewt | 2006-05-20 00:33:14 +0000
 added datetime parser types for the dbs I can find them for

r1724@moss (orig r1723):  matthewt | 2006-05-19 17:54:41 -0700
 r8763@cain (orig r1714):  matthewt | 2006-05-20 00:34:39 +0000
 added datetime parser for MSSQL (ta LTJake)

r1725@moss (orig r1724):  matthewt | 2006-05-19 17:54:44 -0700

r1726@moss (orig r1725):  matthewt | 2006-05-19 18:14:38 -0700
futz changes, fix populate. I'm a retard.
r1731@moss (orig r1730):  claco | 2006-05-20 13:40:55 -0700
Added delete_related tests to verify it only deletes related records
r1763@moss (orig r1762):  matthewt | 2006-05-23 10:42:15 -0700
Sodding three-value for conditions
r1764@moss (orig r1763):  semifor | 2006-05-23 11:17:16 -0700
Just the column name, please.

r1768@moss (orig r1767):  matthewt | 2006-05-23 14:25:28 -0700
 r5824@cain (orig r1577):  captainL | 2006-05-08 15:30:56 +0000
 first version of refactored resultset

r1769@moss (orig r1768):  matthewt | 2006-05-23 14:25:36 -0700
 r5825@cain (orig r1578):  captainL | 2006-05-08 16:05:40 +0000
 better comments. resolution not done every time.

r1770@moss (orig r1769):  matthewt | 2006-05-23 14:25:39 -0700
 r5839@cain (orig r1592):  captainL | 2006-05-09 15:53:19 +0000
 failing test case and more resultset refactorage

r1771@moss (orig r1770):  matthewt | 2006-05-23 14:27:23 -0700
 r5885@cain (orig r1610):  captainL | 2006-05-11 10:44:44 +0000
 can now handle prefetch on resultset with join of same name

r1772@moss (orig r1771):  matthewt | 2006-05-23 14:27:26 -0700
 r5887@cain (orig r1612):  captainL | 2006-05-11 12:21:49 +0000
 merged recent -current changes into this branch

r1773@moss (orig r1772):  matthewt | 2006-05-23 14:27:47 -0700
 r5905@cain (orig r1618):  captainL | 2006-05-12 11:38:30 +0000
 proper deep merging on join attrs

r1774@moss (orig r1773):  matthewt | 2006-05-23 14:27:49 -0700
 r8824@cain (orig r1745):  captainL | 2006-05-22 13:12:18 +0000
 join merging working properly. some torture tests

r1775@moss (orig r1774):  matthewt | 2006-05-23 14:27:53 -0700
 r8827@cain (orig r1748):  captainL | 2006-05-22 15:06:16 +0000
 more torture test, cleaned up

r1776@moss (orig r1775):  matthewt | 2006-05-23 14:27:56 -0700
 r8828@cain (orig r1749):  captainL | 2006-05-22 15:23:44 +0000
 arg. bugfix

r1777@moss (orig r1776):  matthewt | 2006-05-23 14:27:59 -0700

r1778@moss (orig r1777):  matthewt | 2006-05-23 14:28:04 -0700
 r8844@cain (orig r1765):  matthewt | 2006-05-23 21:23:01 +0000
 works. win.

r1779@moss (orig r1778):  matthewt | 2006-05-23 14:28:08 -0700
 r8845@cain (orig r1766):  matthewt | 2006-05-23 21:23:49 +0000
 fixed screwed merge of Storage::DBI (my fault :)

r1781@moss (orig r1780):  gphat | 2006-05-23 14:48:56 -0700
Add support for +select and +as attributes to ResultSet

r1792@moss (orig r1791):  captainL | 2006-05-24 07:06:35 -0700
added changes from resultset-new-refactor
r1793@moss (orig r1792):  captainL | 2006-05-24 07:09:13 -0700
moved my name to correct place in list
r1797@moss (orig r1796):  bluefeet | 2006-05-24 13:08:16 -0700
 r1762@moss (orig r1761):  ash | 2006-05-23 08:36:07 -0700
 Added docs for quote_char, name_sep and offset RS attrib.

r1801@moss (orig r1800):  matthewt | 2006-05-24 16:30:34 -0700
marked DBIx::Class::DB as deprecated and due to be removed by 1.0
r1807@moss (orig r1806):  bluefeet | 2006-05-25 09:16:28 -0700
Added TODO about changes to the rows attribute.
r1809@moss (orig r1808):  bluefeet | 2006-05-25 09:53:55 -0700
 r1808@moss (orig r1807):  jguenther | 2006-05-25 09:53:12 -0700
 Changed txn_do docs/Cookbook example to use closures, and made their content more consistent

r1811@moss (orig r1810):  bluefeet | 2006-05-25 10:04:25 -0700
 r1655@moss (orig r1654):  bluefeet | 2006-05-17 20:58:32 -0700
 Removed BasicRels and reorganized where the various init/setup code resides.

r1813@moss (orig r1812):  matthewt | 2006-05-25 11:19:21 -0700
piss off
r1814@moss (orig r1813):  bluefeet | 2006-05-25 11:24:20 -0700
 r1656@moss (orig r1655):  bluefeet | 2006-05-17 22:15:24 -0700
 Delete basicrels tests. Modify run tests to use new syntax.  Remove helperrels test wrappers.

r1816@moss (orig r1815):  bluefeet | 2006-05-25 11:34:59 -0700
Delete t/run/ and t/helperrels/ so that the reorganize_tests branch can merge in easly.
r1817@moss (orig r1816):  bluefeet | 2006-05-25 11:35:46 -0700
 r1657@moss (orig r1656):  bluefeet | 2006-05-17 22:28:10 -0700
 Move helperrels/26sqlt.t, and all t/run/*.tl scripts, to t/*.t

r1818@moss (orig r1817):  bluefeet | 2006-05-25 11:36:02 -0700
 r1658@moss (orig r1657):  bluefeet | 2006-05-17 23:44:53 -0700
 Fixes to tests so that they pass.

r1819@moss (orig r1818):  bluefeet | 2006-05-25 11:36:18 -0700

r1820@moss (orig r1819):  bluefeet | 2006-05-25 11:36:23 -0700
 r1795@moss (orig r1794):  bluefeet | 2006-05-24 12:50:31 -0700
 Move relationships out of Relationships.pm and in to the respective classes.  Removed references to PK::Auto.

r1821@moss (orig r1820):  bluefeet | 2006-05-25 11:36:42 -0700
 r1796@moss (orig r1795):  bluefeet | 2006-05-24 12:52:08 -0700
 Move population code from Schema to DBICTest.

r1822@moss (orig r1821):  bluefeet | 2006-05-25 11:36:50 -0700

r1823@moss (orig r1822):  bluefeet | 2006-05-25 11:36:55 -0700
 r1799@moss (orig r1798):  bluefeet | 2006-05-24 14:53:03 -0700
 Incorporate changes in -current.

r1824@moss (orig r1823):  bluefeet | 2006-05-25 11:37:10 -0700

r1825@moss (orig r1824):  bluefeet | 2006-05-25 11:37:16 -0700

r1826@moss (orig r1825):  bluefeet | 2006-05-25 11:37:23 -0700

r1829@moss (orig r1828):  bluefeet | 2006-05-25 11:39:07 -0700
 r1828@moss (orig r1827):  bluefeet | 2006-05-25 11:38:50 -0700
 Remove basicrels, helperrels, and run on t/.

r1832@moss (orig r1831):  jguenther | 2006-05-25 14:12:00 -0700
Squashed an extraneous warning in 82cascade_copy.t and fixed up 26dumper.t
r1833@moss (orig r1832):  jguenther | 2006-05-25 14:17:57 -0700
Changed tests to use DBICTest->init_schema() instead of DBICTest::init_schema()
r1837@moss (orig r1836):  jguenther | 2006-05-25 16:27:00 -0700
squashed a couple unnecessary warnings in the CDBI-compat tests
r1846@moss (orig r1845):  matthewt | 2006-05-26 07:36:38 -0700
hopefully fixup pg tests (thanks to zby, all bugs mine)
r1848@moss (orig r1847):  jguenther | 2006-05-26 11:59:01 -0700
Add a warning for DBD::Pg < 1.49
r1872@moss (orig r1856):  dwc | 2006-05-27 18:30:16 -0700
Add automatic naming of unique constraints
r1873@moss (orig r1857):  dwc | 2006-05-27 18:31:20 -0700
Fix POD for name_unique_constraint
r1874@moss (orig r1858):  dwc | 2006-05-27 18:32:24 -0700
Remove tabs from recent Changes
r1876@moss (orig r1860):  dwc | 2006-05-28 10:09:20 -0700
 r9272@fortuna (orig r1790):  dwc | 2006-05-24 01:57:22 -0400
 First pass: take what the user provides if we can't determine a unique query

r1877@moss (orig r1861):  dwc | 2006-05-28 10:09:28 -0700

r1878@moss (orig r1862):  dwc | 2006-05-28 10:09:35 -0700

r1879@moss (orig r1863):  dwc | 2006-05-28 10:09:41 -0700

r1880@moss (orig r1864):  dwc | 2006-05-28 10:09:49 -0700

r1881@moss (orig r1865):  dwc | 2006-05-28 10:09:55 -0700
 r9326@fortuna (orig r1835):  dwc | 2006-05-25 19:03:12 -0400
 Add a test for a search on a partial key, followed by a find

r1882@moss (orig r1866):  dwc | 2006-05-28 10:10:02 -0700
 r9328@fortuna (orig r1837):  dwc | 2006-05-25 20:05:07 -0400
 Revert to old find and update_or_create algorithms for now

r1883@moss (orig r1867):  dwc | 2006-05-28 10:10:10 -0700
 r9329@fortuna (orig r1838):  dwc | 2006-05-25 20:16:45 -0400
 Hack for now, constraint in find if a key is specified

r1884@moss (orig r1868):  dwc | 2006-05-28 10:10:17 -0700
 r9330@fortuna (orig r1839):  dwc | 2006-05-26 00:09:26 -0400
 Restore stricter find, but with compat warnings.  find_related and friends cause extraneous warnngs; not sure how to deal with this yet.

r1885@moss (orig r1869):  dwc | 2006-05-28 10:10:23 -0700
 r9331@fortuna (orig r1840):  dwc | 2006-05-26 00:14:48 -0400
 Use stricter find in update_or_create again

r1886@moss (orig r1870):  dwc | 2006-05-28 10:10:29 -0700
 r9332@fortuna (orig r1841):  dwc | 2006-05-26 00:35:59 -0400
 Minor update to find_or_create docs re: how it searches

r1887@moss (orig r1871):  dwc | 2006-05-28 10:10:35 -0700

r1888@moss (orig r1872):  dwc | 2006-05-28 10:10:42 -0700
 r9334@fortuna (orig r1843):  dwc | 2006-05-26 00:56:36 -0400
 Refactor query building and verification so the warnings come from find

r1889@moss (orig r1873):  dwc | 2006-05-28 10:10:48 -0700
 r9339@fortuna (orig r1844):  dwc | 2006-05-26 10:35:01 -0400
 Update naming for consistency with CDBICompat _build_query method

r1890@moss (orig r1874):  dwc | 2006-05-28 10:10:54 -0700

r1891@moss (orig r1875):  dwc | 2006-05-28 10:11:01 -0700

r1892@moss (orig r1876):  dwc | 2006-05-28 10:11:07 -0700
 r9351@fortuna (orig r1851):  dwc | 2006-05-27 18:06:35 -0400
 Relax _unique_queries for *_related

r1893@moss (orig r1877):  dwc | 2006-05-28 10:11:18 -0700
 r9352@fortuna (orig r1852):  dwc | 2006-05-27 19:33:15 -0400
 First pass at verifying query uniqueness: Recursively collapse AST, acculumulating values at the leafs.  If we get exactly one value for each unique column, we know the query is unique.

r1894@moss (orig r1878):  dwc | 2006-05-28 10:11:24 -0700
 r9353@fortuna (orig r1853):  dwc | 2006-05-27 19:39:20 -0400
 Fix for extraneous warning in 65multipk

r1895@moss (orig r1879):  dwc | 2006-05-28 10:11:30 -0700
 r9354@fortuna (orig r1854):  dwc | 2006-05-27 20:00:08 -0400
 Minor cleanup

r1896@moss (orig r1880):  dwc | 2006-05-28 10:11:36 -0700
 r9355@fortuna (orig r1855):  dwc | 2006-05-27 20:06:02 -0400
 Another minor cleanup

r1898@moss (orig r1882):  dwc | 2006-05-28 10:39:55 -0700
Changes for 0.06999_01 release
r1899@moss (orig r1883):  bluefeet | 2006-05-28 11:11:16 -0700
Added test reorganization under 0.06999_01 in Changes file.
r1900@moss (orig r1884):  bluefeet | 2006-05-28 12:24:11 -0700
Added Ordered as an additional change in 0.06999_01.  Added myself (bluefeet) as a contributor in Class.pm.
r1901@moss (orig r1885):  bluefeet | 2006-05-28 12:26:44 -0700
Renamed AutoInflate::DateTime to InfalteColumn::DateTime in Changes.
r1902@moss (orig r1886):  bluefeet | 2006-05-28 22:49:45 -0700
POD for InflateColumn::DateTime.

148 files changed:
Changes
Makefile.PL
TODO
lib/DBIx/Class.pm
lib/DBIx/Class/DB.pm
lib/DBIx/Class/InflateColumn/DateTime.pm [new file with mode: 0644]
lib/DBIx/Class/Manual/Cookbook.pod
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/ResultSetManager.pm
lib/DBIx/Class/ResultSource.pm
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm
lib/DBIx/Class/Storage/DBI/DB2.pm
lib/DBIx/Class/Storage/DBI/MSSQL.pm
lib/DBIx/Class/Storage/DBI/ODBC400.pm [new file with mode: 0644]
lib/DBIx/Class/Storage/DBI/Pg.pm
t/19quotes.t
t/26dumper.t
t/31stats.t
t/53delete_related.t [new file with mode: 0644]
t/60core.t [moved from t/run/01core.tl with 93% similarity]
t/64db.t [moved from t/run/04db.tl with 91% similarity]
t/65multipk.t [moved from t/run/05multipk.tl with 56% similarity]
t/66relationship.t [moved from t/run/06relationship.tl with 93% similarity]
t/67pager.t [moved from t/run/07pager.tl with 92% similarity]
t/68inflate.t [moved from t/run/08inflate.tl with 84% similarity]
t/68inflate_has_a.t [moved from t/run/08inflate_has_a.tl with 91% similarity]
t/68inflate_serialize.t [moved from t/run/08inflate_serialize.tl with 93% similarity]
t/69update.t [moved from t/run/09update.tl with 83% similarity]
t/70auto.t [moved from t/run/10auto.tl with 81% similarity]
t/71mysql.t [moved from t/run/11mysql.tl with 91% similarity]
t/72pg.t [moved from t/run/12pg.tl with 79% similarity]
t/73oracle.t [moved from t/run/13oracle.tl with 91% similarity]
t/745db2.t [moved from t/run/145db2.tl with 91% similarity]
t/746db2_400.t [moved from t/run/146db2_400.tl with 91% similarity]
t/74mssql.t [moved from t/run/14mssql.tl with 79% similarity]
t/75limit.t [moved from t/run/15limit.tl with 93% similarity]
t/76joins.t [moved from t/run/16joins.tl with 92% similarity]
t/77join_count.t [moved from t/run/17join_count.tl with 87% similarity]
t/78self_referencial.t [moved from t/run/18self_referencial.tl with 88% similarity]
t/79uuid.t [moved from t/run/19uuid.tl with 64% similarity]
t/80unique.t [moved from t/run/20unique.tl with 84% similarity]
t/81transactions.t [moved from t/run/21transactions.tl with 97% similarity]
t/82cascade_copy.t [moved from t/run/22cascade_copy.tl with 84% similarity]
t/83cache.t [moved from t/run/23cache.tl with 96% similarity]
t/84serialize.t [moved from t/run/24serialize.tl with 62% similarity]
t/85utf8.t [new file with mode: 0644]
t/86might_have.t [moved from t/run/26might_have.tl with 87% similarity]
t/86sqlt.t [moved from t/helperrels/26sqlt.t with 93% similarity]
t/87ordered.t [moved from t/run/27ordered.tl with 69% similarity]
t/88result_set_column.t [new file with mode: 0644]
t/89dbicadmin.t [new file with mode: 0644]
t/89inflate_datetime.t [new file with mode: 0644]
t/90ensure_class_loaded.t [moved from t/run/30ensure_class_loaded.tl with 87% similarity]
t/90join_torture.t [new file with mode: 0644]
t/basicrels/01core.t [deleted file]
t/basicrels/04db.t [deleted file]
t/basicrels/05multipk.t [deleted file]
t/basicrels/06relationship.t [deleted file]
t/basicrels/07pager.t [deleted file]
t/basicrels/08inflate.t [deleted file]
t/basicrels/08inflate_has_a.t [deleted file]
t/basicrels/08inflate_serialize.t [deleted file]
t/basicrels/09update.t [deleted file]
t/basicrels/10auto.t [deleted file]
t/basicrels/11mysql.t [deleted file]
t/basicrels/12pg.t [deleted file]
t/basicrels/13oracle.t [deleted file]
t/basicrels/145db2.t [deleted file]
t/basicrels/146db2_400.t [deleted file]
t/basicrels/14mssql.t [deleted file]
t/basicrels/15limit.t [deleted file]
t/basicrels/16joins.t [deleted file]
t/basicrels/17join_count.t [deleted file]
t/basicrels/18self_referencial.t [deleted file]
t/basicrels/19uuid.t [deleted file]
t/basicrels/20unique.t [deleted file]
t/basicrels/21transactions.t [deleted file]
t/basicrels/22cascade_copy.t [deleted file]
t/basicrels/23cache.t [deleted file]
t/basicrels/24serialize.t [deleted file]
t/basicrels/25utf8.t [deleted file]
t/basicrels/26might_have.t [deleted file]
t/basicrels/28result_set_column.t [deleted file]
t/basicrels/30ensure_class_loaded.t [deleted file]
t/cdbi-sweet-t/08pager.t
t/cdbi-t/01-columns.t
t/cdbi-t/18-has_a.t
t/helperrels/01core.t [deleted file]
t/helperrels/04db.t [deleted file]
t/helperrels/05multipk.t [deleted file]
t/helperrels/06relationship.t [deleted file]
t/helperrels/07pager.t [deleted file]
t/helperrels/08inflate.t [deleted file]
t/helperrels/08inflate_has_a.t [deleted file]
t/helperrels/08inflate_serialize.t [deleted file]
t/helperrels/09update.t [deleted file]
t/helperrels/10auto.t [deleted file]
t/helperrels/11mysql.t [deleted file]
t/helperrels/12pg.t [deleted file]
t/helperrels/13oracle.t [deleted file]
t/helperrels/145db2.t [deleted file]
t/helperrels/146db2_400.t [deleted file]
t/helperrels/14mssql.t [deleted file]
t/helperrels/15limit.t [deleted file]
t/helperrels/16joins.t [deleted file]
t/helperrels/17join_count.t [deleted file]
t/helperrels/18self_referencial.t [deleted file]
t/helperrels/19uuid.t [deleted file]
t/helperrels/20unique.t [deleted file]
t/helperrels/21transactions.t [deleted file]
t/helperrels/22cascade_copy.t [deleted file]
t/helperrels/23cache.t [deleted file]
t/helperrels/24serialize.t [deleted file]
t/helperrels/25utf8.t [deleted file]
t/helperrels/26might_have.t [deleted file]
t/helperrels/27ordered.t [deleted file]
t/helperrels/28result_set_column.t [deleted file]
t/helperrels/29dbicadmin.t [deleted file]
t/helperrels/30ensure_class_loaded.t [deleted file]
t/lib/DBICTest.pm
t/lib/DBICTest/BasicRels.pm [deleted file]
t/lib/DBICTest/HelperRels.pm [deleted file]
t/lib/DBICTest/Schema.pm
t/lib/DBICTest/Schema/Artist.pm
t/lib/DBICTest/Schema/ArtistUndirectedMap.pm
t/lib/DBICTest/Schema/BasicRels.pm [deleted file]
t/lib/DBICTest/Schema/Bookmark.pm
t/lib/DBICTest/Schema/CD.pm
t/lib/DBICTest/Schema/CD_to_Producer.pm
t/lib/DBICTest/Schema/Employee.pm
t/lib/DBICTest/Schema/Event.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/HelperRels.pm [deleted file]
t/lib/DBICTest/Schema/Link.pm
t/lib/DBICTest/Schema/OneKey.pm
t/lib/DBICTest/Schema/Producer.pm
t/lib/DBICTest/Schema/SelfRef.pm
t/lib/DBICTest/Schema/SelfRefAlias.pm
t/lib/DBICTest/Schema/Tag.pm
t/lib/DBICTest/Schema/Track.pm
t/lib/DBICTest/Schema/TreeLike.pm
t/lib/DBICTest/Schema/TwoKeyTreeLike.pm
t/lib/DBICTest/Schema/TwoKeys.pm
t/lib/DBICTest/Setup.pm [deleted file]
t/lib/sqlite.sql
t/run/25utf8.tl [deleted file]
t/run/28result_set_column.tl [deleted file]
t/run/29dbicadmin.tl [deleted file]

diff --git a/Changes b/Changes
index 3a51cb7..8ef37bf 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
 Revision history for DBIx::Class
 
+0.06999_01 2006-05-28 17:19:30
+        - add automatic naming of unique constraints
+        - marked DB.pm as deprecated and noted it will be removed by 1.0
+        - add ResultSetColumn
+        - refactor ResultSet code to resolve attrs as late as poss
+        - merge prefetch attrs into join attrs
+        - add +select and +as attributes to ResultSet
+        - added InflateColumn::DateTime component
         - refactor debugging to allow for profiling using Storage::Statistics
         - removed Data::UUID from deps, made other optionals required
         - modified SQLT parser to skip dupe table names
@@ -17,8 +25,10 @@ Revision history for DBIx::Class
           loaded
         - CDBICompat: override find_or_create to fix column casing when
           ColumnCase is loaded
+        - reorganized and simplified tests
+        - added Ordered
 
-0.06003
+0.06003 2006-05-19 15:37:30
         - make find_or_create_related check defined() instead of truth
         - don't unnecessarily fetch rels for cascade_update
         - don't set_columns explicitly in update_or_create; instead use
index 51d31fd..192903a 100644 (file)
       
       # Save this 'cause CPAN will chdir all over the place.
       my $cwd = Cwd::cwd();
-      my $makefile = File::Spec->rel2abs($0);
       
-      CPAN::Shell->install('Module::Build::Compat')
-       or die " *** Cannot install without Module::Build.  Exiting ...\n";
+      CPAN::Shell->install('Module::Build::Compat');
+      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
+       or die "Couldn't install Module::Build, giving up.\n";
       
       chdir $cwd or die "Cannot chdir() back to $cwd: $!";
     }
     eval "use Module::Build::Compat 0.02; 1" or die $@;
-    use lib '_build/lib';
+    
     Module::Build::Compat->run_build_pl(args => \@ARGV);
     require Module::Build;
     Module::Build::Compat->write_makefile(build_class => 'Module::Build');
diff --git a/TODO b/TODO
index 136e01a..e22c6ba 100644 (file)
--- a/TODO
+++ b/TODO
  SQLT modules so an app can do its own deploy without SQLT on the target 
  system
 
+2006-05-25 by mst (TODOed by bluefeet)
+ Add the search attributes "limit" and "rows_per_page".
+ limit: work as expected just like offset does
+ rows_per_page: only be used if you used the page attr or called $rs->page
+ rows: modify to be an alias that gets used to populate either as appropriate, 
+       if you haven't specified one of the others
 
index 75b87d6..543279e 100644 (file)
@@ -13,7 +13,7 @@ sub component_base_class { 'DBIx::Class' }
 # 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.06002';
+$VERSION = '0.06999_01';
 
 sub MODIFY_CODE_ATTRIBUTES {
     my ($class,$code,@attrs) = @_;
@@ -182,6 +182,8 @@ ank: Andres Kievsky
 
 blblack: Brandon Black
 
+bluefeet: Aran Deltac <bluefeet@cpan.org>
+
 LTJake: Brian Cassidy <bricas@cpan.org>
 
 claco: Christopher H. Laco
@@ -206,6 +208,8 @@ quicksilver: Jules Bean
 
 jguenther: Justin Guenther <guentherj@agr.gc.ca>
 
+captainL: Luke Saunders <luke.saunders@gmail.com>
+
 draven: Marcus Ramberg <mramberg@cpan.org>
 
 nigel: Nigel Metheringham <nigelm@cpan.org>
@@ -222,8 +226,6 @@ scotty: Scotty Allen <scotty@scottyallen.com>
 
 sszabo: Stephan Szabo <sszabo@bigpanda.com>
 
-captainL: Luke Saunders <luke.saunders@gmail.com>
-
 Todd Lipcon
 
 wdh: Will Hawes
index aa5eeb3..9e67f5c 100644 (file)
@@ -31,7 +31,7 @@ sub resultset_instance {
 
 =head1 NAME
 
-DBIx::Class::DB - Non-recommended classdata schema component
+DBIx::Class::DB - (DEPRECATED) classdata schema component
 
 =head1 SYNOPSIS
 
@@ -54,8 +54,8 @@ DBIx::Class::DB - Non-recommended classdata schema component
 
 This class is designed to support the Class::DBI connection-as-classdata style
 for DBIx::Class. You are *strongly* recommended to use a DBIx::Class::Schema
-instead; DBIx::Class::DB will continue to be supported but new development
-will be focused on Schema-based DBIx::Class setups.
+instead; DBIx::Class::DB will not undergo new development and will be moved
+to being a CDBICompat-only component before 1.0.
 
 =head1 METHODS
 
diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm
new file mode 100644 (file)
index 0000000..24f9e48
--- /dev/null
@@ -0,0 +1,92 @@
+package DBIx::Class::InflateColumn::DateTime;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class/;
+
+=head1 NAME
+
+DBIx::Class::InflateColumn::DateTime - Auto-create DateTime objects from datetime columns.
+
+=head1 SYNOPSIS
+
+Load this component and then declare one or more 
+columns to be of the datetime datatype.
+
+  package Event;
+  __PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+  __PACKAGE__->add_columns(
+    starts_when => { data_type => 'datetime' }
+  );
+
+Then you can treat the specified column as a L<DateTime> object.
+
+  print "This event starts the month of ".
+    $event->starts_when->month_name();
+
+=head1 DESCRIPTION
+
+This module figures out the type of DateTime::Format::* class to 
+inflate/deflate with based on the type of DBIx::Class::Storage::DBI::* 
+that you are using.  If you switch from one database to a different 
+one your code will continue to work without modification.
+
+=cut
+
+__PACKAGE__->load_components(qw/InflateColumn/);
+
+__PACKAGE__->mk_group_accessors('simple' => '__datetime_parser');
+
+sub register_column {
+  my ($self, $column, $info, @rest) = @_;
+  $self->next::method($column, $info, @rest);
+  if ($info->{data_type} =~ /^datetime$/i) {
+    $self->inflate_column(
+      $column =>
+        {
+          inflate => sub {
+            my ($value, $obj) = @_;
+            $obj->_datetime_parser->parse_datetime($value);
+          },
+          deflate => sub {
+            my ($value, $obj) = @_;
+            $obj->_datetime_parser->format_datetime($value);
+          },
+        }
+    );
+  }
+}
+
+sub _datetime_parser {
+  my $self = shift;
+  if (my $parser = $self->__datetime_parser) {
+    return $parser;
+  }
+  my $parser = $self->result_source->storage->datetime_parser(@_);
+  return $self->__datetime_parser($parser);
+}
+
+1;
+__END__
+
+=head1 SEE ALSO
+
+=over 4
+
+=item More information about the add_columns method, and column metadata, 
+      can be found in the documentation for L<DBIx::Class::ResultSource>.
+
+=back
+
+=head1 AUTHOR
+
+Matt S. Trout <mst@shadowcatsystems.co.uk>
+
+=head1 CONTRIBUTORS
+
+Aran Deltac <bluefeet@cpan.org>
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
index f83d7ee..9f2a8fa 100644 (file)
@@ -313,9 +313,8 @@ L<DBIx::Class> has now prefetched all matching data from the C<artist> table,
 so no additional SQL statements are executed. You now have a much more
 efficient query.
 
-Note that as of L<DBIx::Class> 0.04, C<prefetch> cannot be used with
-C<has_many> relationships. You will get an error along the lines of "No
-accessor for prefetched ..." if you try.
+Note that as of L<DBIx::Class> 0.05999_01, C<prefetch> I<can> be used with
+C<has_many> relationships.
 
 Also note that C<prefetch> should only be used when you know you will
 definitely use data from a related table. Pre-fetching related tables when you
@@ -410,24 +409,22 @@ example of the recommended way to use it:
 
   my $genus = $schema->resultset('Genus')->find(12);
 
+  my $coderef2 = sub {
+    $genus->extinct(1);
+    $genus->update;
+  };
+
   my $coderef1 = sub {
-    my ($schema, $genus, $code) = @_;
     $genus->add_to_species({ name => 'troglodyte' });
     $genus->wings(2);
     $genus->update;
-    $schema->txn_do($code, $genus); # Can have a nested transaction
+    $schema->txn_do($coderef2); # Can have a nested transaction
     return $genus->species;
   };
 
-  my $coderef2 = sub {
-    my ($genus) = @_;
-    $genus->extinct(1);
-    $genus->update;
-  };
-
   my $rs;
   eval {
-    $rs = $schema->txn_do($coderef1, $schema, $genus, $coderef2);
+    $rs = $schema->txn_do($coderef1);
   };
 
   if ($@) {                             # Transaction failed
index 49d615f..ec41bc5 100644 (file)
@@ -6,8 +6,10 @@ use overload
         '0+'     => \&count,
         'bool'   => sub { 1; },
         fallback => 1;
+use Carp::Clan qw/^DBIx::Class/;
 use Data::Page;
 use Storable;
+use Data::Dumper;
 use Scalar::Util qw/weaken/;
 
 use DBIx::Class::ResultSetColumn;
@@ -86,68 +88,6 @@ sub new {
   
   my ($source, $attrs) = @_;
   weaken $source;
-  $attrs = Storable::dclone($attrs || {}); # { %{ $attrs || {} } };
-  #use Data::Dumper; warn Dumper($attrs);
-  my $alias = ($attrs->{alias} ||= 'me');
-  
-  $attrs->{columns} ||= delete $attrs->{cols} if $attrs->{cols};
-  delete $attrs->{as} if $attrs->{columns};
-  $attrs->{columns} ||= [ $source->columns ] unless $attrs->{select};
-  $attrs->{select} = [
-    map { m/\./ ? $_ : "${alias}.$_" } @{delete $attrs->{columns}}
-  ] if $attrs->{columns};
-  $attrs->{as} ||= [
-    map { m/^\Q$alias.\E(.+)$/ ? $1 : $_ } @{$attrs->{select}}
-  ];
-  if (my $include = delete $attrs->{include_columns}) {
-    push(@{$attrs->{select}}, @$include);
-    push(@{$attrs->{as}}, map { m/([^.]+)$/; $1; } @$include);
-  }
-  #use Data::Dumper; warn Dumper(@{$attrs}{qw/select as/});
-
-  $attrs->{from} ||= [ { $alias => $source->from } ];
-  $attrs->{seen_join} ||= {};
-  my %seen;
-  if (my $join = delete $attrs->{join}) {
-    foreach my $j (ref $join eq 'ARRAY' ? @$join : ($join)) {
-      if (ref $j eq 'HASH') {
-        $seen{$_} = 1 foreach keys %$j;
-      } else {
-        $seen{$j} = 1;
-      }
-    }
-    push(@{$attrs->{from}}, $source->resolve_join(
-      $join, $attrs->{alias}, $attrs->{seen_join})
-    );
-  }
-  
-  $attrs->{group_by} ||= $attrs->{select} if delete $attrs->{distinct};
-  $attrs->{order_by} = [ $attrs->{order_by} ] if
-    $attrs->{order_by} and !ref($attrs->{order_by});
-  $attrs->{order_by} ||= [];
-
-  my $collapse = $attrs->{collapse} || {};
-  if (my $prefetch = delete $attrs->{prefetch}) {
-    my @pre_order;
-    foreach my $p (ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch)) {
-      if ( ref $p eq 'HASH' ) {
-        foreach my $key (keys %$p) {
-          push(@{$attrs->{from}}, $source->resolve_join($p, $attrs->{alias}))
-            unless $seen{$key};
-        }
-      } else {
-        push(@{$attrs->{from}}, $source->resolve_join($p, $attrs->{alias}))
-            unless $seen{$p};
-      }
-      my @prefetch = $source->resolve_prefetch(
-           $p, $attrs->{alias}, {}, \@pre_order, $collapse);
-      push(@{$attrs->{select}}, map { $_->[0] } @prefetch);
-      push(@{$attrs->{as}}, map { $_->[1] } @prefetch);
-    }
-    push(@{$attrs->{order_by}}, @pre_order);
-  }
-  $attrs->{collapse} = $collapse;
-#  use Data::Dumper; warn Dumper($collapse) if keys %{$collapse};
 
   if ($attrs->{page}) {
     $attrs->{rows} ||= 10;
@@ -155,12 +95,14 @@ sub new {
     $attrs->{offset} += ($attrs->{rows} * ($attrs->{page} - 1));
   }
 
+  $attrs->{alias} ||= 'me';
+
   bless {
     result_source => $source,
     result_class => $attrs->{result_class} || $source->result_class,
     cond => $attrs->{where},
-    from => $attrs->{from},
-    collapse => $collapse,
+#    from => $attrs->{from},
+#    collapse => $collapse,
     count => undef,
     page => delete $attrs->{page},
     pager => undef,
@@ -218,10 +160,29 @@ always return a resultset, even in list context.
 sub search_rs {
   my $self = shift;
 
-  my $attrs = { %{$self->{attrs}} };
-  my $having = delete $attrs->{having};
-  $attrs = { %$attrs, %{ pop(@_) } } if @_ > 1 and ref $_[$#_] eq 'HASH';
+  my $our_attrs = { %{$self->{attrs}} };
+  my $having = delete $our_attrs->{having};
+  my $attrs = {};
+  $attrs = pop(@_) if @_ > 1 and ref $_[$#_] eq 'HASH';
+  
+  # merge new attrs into old
+  foreach my $key (qw/join prefetch/) {
+    next unless (exists $attrs->{$key});
+    if (exists $our_attrs->{$key}) {
+      $our_attrs->{$key} = $self->_merge_attr($our_attrs->{$key}, $attrs->{$key});
+    } else {
+      $our_attrs->{$key} = $attrs->{$key};
+    }
+    delete $attrs->{$key};
+  }
+
+  if (exists $our_attrs->{prefetch}) {
+      $our_attrs->{join} = $self->_merge_attr($our_attrs->{join}, $our_attrs->{prefetch}, 1);
+  }
+
+  my $new_attrs = { %{$our_attrs}, %{$attrs} };
 
+  # merge new where and having into old
   my $where = (@_
                 ? ((@_ == 1 || ref $_[0] eq "HASH")
                     ? shift
@@ -231,22 +192,23 @@ sub search_rs {
                         : {@_}))
                 : undef());
   if (defined $where) {
-    $attrs->{where} = (defined $attrs->{where}
+    $new_attrs->{where} = (defined $new_attrs->{where}
               ? { '-and' =>
                   [ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
-                      $where, $attrs->{where} ] }
+                      $where, $new_attrs->{where} ] }
               : $where);
   }
 
   if (defined $having) {
-    $attrs->{having} = (defined $attrs->{having}
+    $new_attrs->{having} = (defined $new_attrs->{having}
               ? { '-and' =>
                   [ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
-                      $having, $attrs->{having} ] }
+                      $having, $new_attrs->{having} ] }
               : $having);
   }
 
-  my $rs = (ref $self)->new($self->result_source, $attrs);
+  my $rs = (ref $self)->new($self->result_source, $new_attrs);
+  $rs->{_parent_rs} = $self->{_parent_rs} if ($self->{_parent_rs}); #XXX - hack to pass through parent of related resultsets
 
   unless (@_) { # no search, effectively just a clone
     my $rows = $self->get_cache;
@@ -301,7 +263,7 @@ a row by its primary key:
 You can also find a row by a specific unique constraint using the C<key>
 attribute. For example:
 
-  my $cd = $schema->resultset('CD')->find('Massive Attack', 'Mezzanine', { key => 'artist_title' });
+  my $cd = $schema->resultset('CD')->find('Massive Attack', 'Mezzanine', { key => 'cd_artist_title' });
 
 Additionally, you can specify the columns explicitly by name:
 
@@ -310,14 +272,14 @@ Additionally, you can specify the columns explicitly by name:
       artist => 'Massive Attack',
       title  => 'Mezzanine',
     },
-    { key => 'artist_title' }
+    { key => 'cd_artist_title' }
   );
 
-If no C<key> is specified and you explicitly name columns, it searches on all
-unique constraints defined on the source, including the primary key.
-
 If the C<key> is specified as C<primary>, it searches only on the primary key.
 
+If no C<key> is specified, it searches on all unique constraints defined on the
+source, including the primary key.
+
 See also L</find_or_create> and L</update_or_create>. For information on how to
 declare unique constraints, see
 L<DBIx::Class::ResultSource/add_unique_constraint>.
@@ -328,64 +290,77 @@ sub find {
   my $self = shift;
   my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {});
 
-  # Parse out a hash from input
+  # Default to the primary key, but allow a specific key
   my @cols = exists $attrs->{key}
     ? $self->result_source->unique_constraint_columns($attrs->{key})
     : $self->result_source->primary_columns;
+  $self->throw_exception(
+    "Can't find unless a primary key or unique constraint is defined"
+  ) unless @cols;
 
-  my $hash;
+  # Parse out a hashref from input
+  my $input_query;
   if (ref $_[0] eq 'HASH') {
-    $hash = { %{$_[0]} };
+    $input_query = { %{$_[0]} };
   }
   elsif (@_ == @cols) {
-    $hash = {};
-    @{$hash}{@cols} = @_;
+    $input_query = {};
+    @{$input_query}{@cols} = @_;
   }
-  elsif (@_) {
-    # For backwards compatibility
-    $hash = {@_};
+  else {
+    # Compatibility: Allow e.g. find(id => $value)
+    carp "Find by key => value deprecated; please use a hashref instead";
+    $input_query = {@_};
+  }
+
+  my @unique_queries = $self->_unique_queries($input_query, $attrs);
+#  use Data::Dumper; warn Dumper $self->result_source->name, $input_query, \@unique_queries, $self->{attrs}->{where};
+
+  # Handle cases where the ResultSet defines the query, or where the user is
+  # abusing find
+  my $query = @unique_queries ? \@unique_queries : $input_query;
+
+  # Run the query
+  if (keys %$attrs) {
+    my $rs = $self->search($query, $attrs);
+    $rs->_resolve;
+    return keys %{$rs->{_attrs}->{collapse}} ? $rs->next : $rs->single;
   }
   else {
-    $self->throw_exception(
-      "Arguments to find must be a hashref or match the number of columns in the "
-        . (exists $attrs->{key} ? "$attrs->{key} unique constraint" : "primary key")
-    );
+    $self->_resolve;  
+    return (keys %{$self->{_attrs}->{collapse}})
+      ? $self->search($query)->next
+      : $self->single($query);
   }
+}
+
+# _unique_queries
+#
+# Build a list of queries which satisfy unique constraints.
+
+sub _unique_queries {
+  my ($self, $query, $attrs) = @_;
 
-  # Check the hash we just parsed against our source's unique constraints
   my @constraint_names = exists $attrs->{key}
     ? ($attrs->{key})
     : $self->result_source->unique_constraint_names;
-  $self->throw_exception(
-    "Can't find unless a primary key or unique constraint is defined"
-  ) unless @constraint_names;
 
   my @unique_queries;
   foreach my $name (@constraint_names) {
     my @unique_cols = $self->result_source->unique_constraint_columns($name);
-    my $unique_query = $self->_build_unique_query($hash, \@unique_cols);
+    my $unique_query = $self->_build_unique_query($query, \@unique_cols);
+
+    next unless scalar keys %$unique_query;
 
     # Add the ResultSet's alias
     foreach my $key (grep { ! m/\./ } keys %$unique_query) {
-      $unique_query->{"$self->{attrs}{alias}.$key"} = delete $unique_query->{$key};
+      $unique_query->{"$self->{attrs}->{alias}.$key"} = delete $unique_query->{$key};
     }
 
-    push @unique_queries, $unique_query if %$unique_query;
+    push @unique_queries, $unique_query;
   }
 
-  # Handle cases where the ResultSet already defines the query
-  my $query = @unique_queries ? \@unique_queries : undef;
-
-  # Run the query
-  if (keys %$attrs) {
-    my $rs = $self->search($query, $attrs);
-    return keys %{$rs->{collapse}} ? $rs->next : $rs->single;
-  }
-  else {
-    return keys %{$self->{collapse}}
-      ? $self->search($query)->next
-      : $self->single($query);
-  }
+  return @unique_queries;
 }
 
 # _build_unique_query
@@ -443,9 +418,11 @@ L<DBIx::Class::Cursor> for more information.
 
 sub cursor {
   my ($self) = @_;
-  my $attrs = { %{$self->{attrs}} };
+
+  $self->_resolve;
+  my $attrs = { %{$self->{_attrs}} };
   return $self->{cursor}
-    ||= $self->result_source->storage->select($self->{from}, $attrs->{select},
+    ||= $self->result_source->storage->select($attrs->{from}, $attrs->{select},
           $attrs->{where},$attrs);
 }
 
@@ -472,7 +449,8 @@ method; if you need to add extra joins or similar call ->search and then
 
 sub single {
   my ($self, $where) = @_;
-  my $attrs = { %{$self->{attrs}} };
+  $self->_resolve;
+  my $attrs = { %{$self->{_attrs}} };
   if ($where) {
     if (defined $attrs->{where}) {
       $attrs->{where} = {
@@ -484,12 +462,85 @@ sub single {
       $attrs->{where} = $where;
     }
   }
+
+  unless ($self->_is_unique_query($attrs->{where})) {
+    carp "Query not guarnteed to return a single row"
+      . "; please declare your unique constraints or use search instead";
+  }
+
   my @data = $self->result_source->storage->select_single(
-          $self->{from}, $attrs->{select},
+          $attrs->{from}, $attrs->{select},
           $attrs->{where},$attrs);
   return (@data ? $self->_construct_object(@data) : ());
 }
 
+# _is_unique_query
+#
+# Try to determine if the specified query is guaranteed to be unique, based on
+# the declared unique constraints.
+
+sub _is_unique_query {
+  my ($self, $query) = @_;
+
+  my $collapsed = $self->_collapse_query($query);
+#  use Data::Dumper; warn Dumper $query, $collapsed;
+
+  foreach my $name ($self->result_source->unique_constraint_names) {
+    my @unique_cols = map { "$self->{attrs}->{alias}.$_" }
+      $self->result_source->unique_constraint_columns($name);
+
+    # Count the values for each unique column
+    my %seen = map { $_ => 0 } @unique_cols;
+
+    foreach my $key (keys %$collapsed) {
+      my $aliased = $key;
+      $aliased = "$self->{attrs}->{alias}.$key" unless $key =~ /\./;
+
+      next unless exists $seen{$aliased};  # Additional constraints are okay
+      $seen{$aliased} = scalar @{ $collapsed->{$key} };
+    }
+
+    # If we get 0 or more than 1 value for a column, it's not necessarily unique
+    return 1 unless grep { $_ != 1 } values %seen;
+  }
+
+  return 0;
+}
+
+# _collapse_query
+#
+# Recursively collapse the query, accumulating values for each column.
+
+sub _collapse_query {
+  my ($self, $query, $collapsed) = @_;
+
+  $collapsed ||= {};
+
+  if (ref $query eq 'ARRAY') {
+    foreach my $subquery (@$query) {
+      next unless ref $subquery;  # -or
+#      warn "ARRAY: " . Dumper $subquery;
+      $collapsed = $self->_collapse_query($subquery, $collapsed);
+    }
+  }
+  elsif (ref $query eq 'HASH') {
+    if (keys %$query and (keys %$query)[0] eq '-and') {
+      foreach my $subquery (@{$query->{-and}}) {
+#        warn "HASH: " . Dumper $subquery;
+        $collapsed = $self->_collapse_query($subquery, $collapsed);
+      }
+    }
+    else {
+#      warn "LEAF: " . Dumper $query;
+      foreach my $key (keys %$query) {
+        push @{$collapsed->{$key}}, $query->{$key};
+      }
+    }
+  }
+
+  return $collapsed;
+}
+
 =head2 get_column
 
 =over 4
@@ -610,27 +661,164 @@ sub next {
                @{delete $self->{stashed_row}} :
                $self->cursor->next
   );
-#  warn Dumper(\@row); use Data::Dumper;
   return unless (@row);
   return $self->_construct_object(@row);
 }
 
+sub _resolve {
+  my $self = shift;
+
+  return if(exists $self->{_attrs}); #return if _resolve has already been called
+
+  my $attrs = $self->{attrs};  
+  my $source = ($self->{_parent_rs}) ? $self->{_parent_rs} : $self->{result_source};
+
+  # XXX - lose storable dclone
+  my $record_filter = delete $attrs->{record_filter} if (defined $attrs->{record_filter});
+  $attrs = Storable::dclone($attrs || {}); # { %{ $attrs || {} } };
+  $attrs->{record_filter} = $record_filter if ($record_filter);
+  $self->{attrs}->{record_filter} = $record_filter if ($record_filter);
+
+  my $alias = $attrs->{alias};
+  $attrs->{columns} ||= delete $attrs->{cols} if $attrs->{cols};
+  delete $attrs->{as} if $attrs->{columns};
+  $attrs->{columns} ||= [ $self->{result_source}->columns ] unless $attrs->{select};
+  my $select_alias = ($self->{_parent_rs}) ? $self->{attrs}->{_live_join} : $alias;
+  $attrs->{select} = [
+                     map { m/\./ ? $_ : "${select_alias}.$_" } @{delete $attrs->{columns}}
+                     ] if $attrs->{columns};
+  $attrs->{as} ||= [
+                   map { m/^\Q$alias.\E(.+)$/ ? $1 : $_ } @{$attrs->{select}}
+                   ];
+  if (my $include = delete $attrs->{include_columns}) {
+      push(@{$attrs->{select}}, @$include);
+      push(@{$attrs->{as}}, map { m/([^.]+)$/; $1; } @$include);
+  }
+
+  $attrs->{from} ||= [ { $alias => $source->from } ];
+  $attrs->{seen_join} ||= {};
+  my %seen;
+  if (my $join = delete $attrs->{join}) {
+      foreach my $j (ref $join eq 'ARRAY' ? @$join : ($join)) {
+         if (ref $j eq 'HASH') {
+             $seen{$_} = 1 foreach keys %$j;
+         } else {
+             $seen{$j} = 1;
+         }
+      }
+
+      push(@{$attrs->{from}}, $source->resolve_join($join, $attrs->{alias}, $attrs->{seen_join}));
+  }
+  $attrs->{group_by} ||= $attrs->{select} if delete $attrs->{distinct};
+  $attrs->{order_by} = [ $attrs->{order_by} ] if
+      $attrs->{order_by} and !ref($attrs->{order_by});
+  $attrs->{order_by} ||= [];
+
+ if(my $seladds = delete($attrs->{'+select'})) {
+   my @seladds = (ref($seladds) eq 'ARRAY' ? @$seladds : ($seladds));
+   $attrs->{select} = [
+     @{ $attrs->{select} },
+     map { (m/\./ || ref($_)) ? $_ : "${alias}.$_" } $seladds
+   ];
+ }
+ if(my $asadds = delete($attrs->{'+as'})) {
+   my @asadds = (ref($asadds) eq 'ARRAY' ? @$asadds : ($asadds));
+   $attrs->{as} = [ @{ $attrs->{as} }, @asadds ];
+ }
+  
+  my $collapse = $attrs->{collapse} || {};
+  if (my $prefetch = delete $attrs->{prefetch}) {
+      my @pre_order;
+      foreach my $p (ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch)) {
+         if ( ref $p eq 'HASH' ) {
+             foreach my $key (keys %$p) {
+                 push(@{$attrs->{from}}, $source->resolve_join($p, $attrs->{alias}))
+                     unless $seen{$key};
+             }
+         } else {
+             push(@{$attrs->{from}}, $source->resolve_join($p, $attrs->{alias}))
+                 unless $seen{$p};
+         }
+         my @prefetch = $source->resolve_prefetch(
+                                                  $p, $attrs->{alias}, {}, \@pre_order, $collapse);
+         push(@{$attrs->{select}}, map { $_->[0] } @prefetch);
+         push(@{$attrs->{as}}, map { $_->[1] } @prefetch);
+      }
+      push(@{$attrs->{order_by}}, @pre_order);
+  }
+  $attrs->{collapse} = $collapse;
+  $self->{_attrs} = $attrs;
+}
+
+sub _merge_attr {
+  my ($self, $a, $b, $is_prefetch) = @_;
+    
+  return $b unless $a;
+  if (ref $b eq 'HASH' && ref $a eq 'HASH') {
+               foreach my $key (keys %{$b}) {
+                       if (exists $a->{$key}) {
+             $a->{$key} = $self->_merge_attr($a->{$key}, $b->{$key}, $is_prefetch);
+                       } else {
+             $a->{$key} = delete $b->{$key};
+                       }
+               }
+               return $a;
+  } else {
+               $a = [$a] unless (ref $a eq 'ARRAY');
+               $b = [$b] unless (ref $b eq 'ARRAY');
+
+               my $hash = {};
+               my $array = [];      
+               foreach ($a, $b) {
+                       foreach my $element (@{$_}) {
+             if (ref $element eq 'HASH') {
+                                       $hash = $self->_merge_attr($hash, $element, $is_prefetch);
+             } elsif (ref $element eq 'ARRAY') {
+                                       $array = [@{$array}, @{$element}];
+             } else {  
+                                       if (($b == $_) && $is_prefetch) {
+                                               $self->_merge_array($array, $element, $is_prefetch);
+                                       } else {
+                                               push(@{$array}, $element);
+                                       }
+             }
+                       }
+               }
+
+               if ((keys %{$hash}) && (scalar(@{$array} > 0))) {
+                       return [$hash, @{$array}];
+               } else {        
+                       return (keys %{$hash}) ? $hash : $array;
+               }
+  }
+}
+
+sub _merge_array {
+       my ($self, $a, $b) = @_;
+       $b = [$b] unless (ref $b eq 'ARRAY');
+       # add elements from @{$b} to @{$a} which aren't already in @{$a}
+       foreach my $b_element (@{$b}) {
+               push(@{$a}, $b_element) unless grep {$b_element eq $_} @{$a};
+       }
+}
+
 sub _construct_object {
   my ($self, @row) = @_;
-  my @as = @{ $self->{attrs}{as} };
-  
+  my @as = @{ $self->{_attrs}{as} };
+
   my $info = $self->_collapse_result(\@as, \@row);
-  
   my $new = $self->result_class->inflate_result($self->result_source, @$info);
-  
-  $new = $self->{attrs}{record_filter}->($new)
-    if exists $self->{attrs}{record_filter};
+  $new = $self->{_attrs}{record_filter}->($new)
+    if exists $self->{_attrs}{record_filter};
   return $new;
 }
 
 sub _collapse_result {
   my ($self, $as, $row, $prefix) = @_;
 
+  my $live_join = $self->{attrs}->{_live_join} ||="";
   my %const;
 
   my @copy = @$row;
@@ -650,7 +838,7 @@ sub _collapse_result {
 
   my $info = [ {}, {} ];
   foreach my $key (keys %const) {
-    if (length $key) {
+    if (length $key && $key ne $live_join) {
       my $target = $info;
       my @parts = split(/\./, $key);
       foreach my $p (@parts) {
@@ -666,9 +854,9 @@ sub _collapse_result {
   if (defined $prefix) {
     @collapse = map {
         m/^\Q${prefix}.\E(.+)$/ ? ($1) : ()
-    } keys %{$self->{collapse}}
+    } keys %{$self->{_attrs}->{collapse}}
   } else {
-    @collapse = keys %{$self->{collapse}};
+    @collapse = keys %{$self->{_attrs}->{collapse}};
   };
 
   if (@collapse) {
@@ -678,7 +866,7 @@ sub _collapse_result {
       $target = $target->[1]->{$p} ||= [];
     }
     my $c_prefix = (defined($prefix) ? "${prefix}.${c}" : $c);
-    my @co_key = @{$self->{collapse}{$c_prefix}};
+    my @co_key = @{$self->{_attrs}->{collapse}{$c_prefix}};
     my %co_check = map { ($_, $target->[0]->{$_}); } @co_key;
     my $tree = $self->_collapse_result($as, $row, $c_prefix);
     my (@final, @raw);
@@ -691,10 +879,9 @@ sub _collapse_result {
       $row = $self->{stashed_row} = \@raw;
       $tree = $self->_collapse_result($as, $row, $c_prefix);
     }
-    @$target = (@final ? @final : [ {}, {} ]);
+    @$target = (@final ? @final : [ {}, {} ]); 
       # single empty result to indicate an empty prefetched has_many
   }
-
   return $info;
 }
 
@@ -753,7 +940,9 @@ sub count {
 sub _count { # Separated out so pager can get the full count
   my $self = shift;
   my $select = { count => '*' };
-  my $attrs = { %{ $self->{attrs} } };
+  
+  $self->_resolve;
+  my $attrs = { %{ $self->{_attrs} } };
   if (my $group_by = delete $attrs->{group_by}) {
     delete $attrs->{having};
     my @distinct = (ref $group_by ?  @$group_by : ($group_by));
@@ -769,7 +958,6 @@ sub _count { # Separated out so pager can get the full count
     }
 
     $select = { count => { distinct => \@distinct } };
-    #use Data::Dumper; die Dumper $select;
   }
 
   $attrs->{select} = $select;
@@ -777,7 +965,6 @@ sub _count { # Separated out so pager can get the full count
 
   # offset, order by and page are not needed to count. record_filter is cdbi
   delete $attrs->{$_} for qw/rows offset order_by page pager record_filter/;
-        
   my ($count) = (ref $self)->new($self->result_source, $attrs)->cursor->next;
   return $count;
 }
@@ -820,12 +1007,14 @@ sub all {
 
   my @obj;
 
-  if (keys %{$self->{collapse}}) {
+  # TODO: don't call resolve here
+  $self->_resolve;
+  if (keys %{$self->{_attrs}->{collapse}}) {
+#  if ($self->{attrs}->{prefetch}) {
       # Using $self->cursor->all is really just an optimisation.
       # If we're collapsing has_many prefetches it probably makes
       # very little difference, and this is cleaner than hacking
       # _construct_object to survive the approach
-    $self->cursor->reset;
     my @row = $self->cursor->next;
     while (@row) {
       push(@obj, $self->_construct_object(@row));
@@ -857,6 +1046,8 @@ Resets the resultset's cursor, so you can iterate through the elements again.
 
 sub reset {
   my ($self) = @_;
+  delete $self->{_attrs} if (exists $self->{_attrs});
+
   $self->{all_cache_position} = 0;
   $self->cursor->reset;
   return $self;
@@ -911,7 +1102,7 @@ sub _cond_for_update_delete {
       $cond->{-and} = [];
 
       my @cond = @{$self->{cond}{-and}};
-      for (my $i = 0; $i < @cond - 1; $i++) {
+      for (my $i = 0; $i <= @cond - 1; $i++) {
         my $entry = $cond[$i];
 
         my %hash;
@@ -923,7 +1114,7 @@ sub _cond_for_update_delete {
         }
         else {
           $entry =~ /([^.]+)$/;
-          $hash{$entry} = $cond[++$i];
+          $hash{$1} = $cond[++$i];
         }
 
         push @{$cond->{-and}}, \%hash;
@@ -1186,8 +1377,8 @@ sub create {
 
   $class->find_or_create({ key => $val, ... });
 
-Searches for a record matching the search condition; if it doesn't find one,
-creates one and returns that instead.
+Tries to find a record based on its primary key or unique constraint; if none
+is found, creates one and returns that instead.
 
   my $cd = $schema->resultset('CD')->find_or_create({
     cdid   => 5,
@@ -1204,7 +1395,7 @@ constraint. For example:
       artist => 'Massive Attack',
       title  => 'Mezzanine',
     },
-    { key => 'artist_title' }
+    { key => 'cd_artist_title' }
   );
 
 See also L</find> and L</update_or_create>. For information on how to declare
@@ -1247,7 +1438,7 @@ For example:
       title  => 'Mezzanine',
       year   => 1998,
     },
-    { key => 'artist_title' }
+    { key => 'cd_artist_title' }
   );
 
 If no C<key> is specified, it searches on all unique constraints defined on the
@@ -1263,15 +1454,15 @@ unique constraints, see L<DBIx::Class::ResultSource/add_unique_constraint>.
 sub update_or_create {
   my $self = shift;
   my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {});
-  my $hash = ref $_[0] eq 'HASH' ? shift : {@_};
+  my $cond = ref $_[0] eq 'HASH' ? shift : {@_};
 
-  my $row = $self->find($hash, $attrs);
+  my $row = $self->find($cond);
   if (defined $row) {
-    $row->update($hash);
+    $row->update($cond);
     return $row;
   }
 
-  return $self->create($hash);
+  return $self->create($cond);
 }
 
 =head2 get_cache
@@ -1312,7 +1503,7 @@ than re-querying the database even if the cache attr is not set.
 sub set_cache {
   my ( $self, $data ) = @_;
   $self->throw_exception("set_cache requires an arrayref")
-    if defined($data) && (ref $data ne 'ARRAY');
+      if defined($data) && (ref $data ne 'ARRAY');
   $self->{all_cache} = $data;
 }
 
@@ -1352,28 +1543,28 @@ Returns a related resultset for the supplied relationship name.
 
 sub related_resultset {
   my ( $self, $rel ) = @_;
+
   $self->{related_resultsets} ||= {};
   return $self->{related_resultsets}{$rel} ||= do {
-      #warn "fetching related resultset for rel '$rel'";
+      #warn "fetching related resultset for rel '$rel' " . $self->result_source->{name};
       my $rel_obj = $self->result_source->relationship_info($rel);
       $self->throw_exception(
         "search_related: result source '" . $self->result_source->name .
         "' has no such relationship ${rel}")
         unless $rel_obj; #die Dumper $self->{attrs};
 
-      my $rs = $self->search(undef, { join => $rel });
-      my $alias = defined $rs->{attrs}{seen_join}{$rel}
-                    && $rs->{attrs}{seen_join}{$rel} > 1
-                  ? join('_', $rel, $rs->{attrs}{seen_join}{$rel})
-                  : $rel;
-
-      $self->result_source->schema->resultset($rel_obj->{class}
+      my $rs = $self->result_source->schema->resultset($rel_obj->{class}
            )->search( undef,
-             { %{$rs->{attrs}},
-               alias => $alias,
+             { %{$self->{attrs}},
                select => undef,
-               as => undef }
+               as => undef,
+              join => $rel,
+              _live_join => $rel }
            );
+
+      # keep reference of the original resultset
+      $rs->{_parent_rs} = $self->result_source;
+      return $rs;
   };
 }
 
@@ -1407,6 +1598,11 @@ Which column(s) to order the results by. This is currently passed
 through directly to SQL, so you can give e.g. C<year DESC> for a
 descending order on the column `year'.
 
+Please note that if you have quoting enabled (see 
+L<DBIx::Class::Storage/quote_char>) you will need to do C<\'year DESC' > to
+specify an order. (The scalar ref causes it to be passed as raw sql to the DB,
+so you will need to manually quote things as appropriate.)
+
 =head2 columns
 
 =over 4
@@ -1462,6 +1658,23 @@ When you use function/stored procedure names and do not supply an C<as>
 attribute, the column names returned are storage-dependent. E.g. MySQL would
 return a column named C<count(employeeid)> in the above example.
 
+=head2 +select
+
+=over 4
+
+Indicates additional columns to be selected from storage.  Works the same as
+L<select> but adds columns to the selection.
+
+=back
+
+=head2 +as
+
+=over 4
+
+Indicates additional column names for those added via L<+select>.
+
+=back
+
 =head2 as
 
 =over 4
@@ -1606,7 +1819,9 @@ with an accessor type of 'single' or 'filter').
 
 Makes the resultset paged and specifies the page to retrieve. Effectively
 identical to creating a non-pages resultset and then calling ->page($page)
-on it.
+on it. 
+
+If L<rows> attribute is not specified it defualts to 10 rows per page.
 
 =head2 rows
 
@@ -1619,6 +1834,17 @@ on it.
 Specifes the maximum number of rows for direct retrieval or the number of
 rows per page if the page attribute or method is used.
 
+=head2 offset
+
+=over 4
+
+=item Value: $offset
+
+=back
+
+Specifies the (zero-based) row number for the  first row to be returned, or the
+of the first row of the first page if paging is used.
+
 =head2 group_by
 
 =over 4
index a0911bc..f5a62b4 100644 (file)
@@ -22,7 +22,7 @@ use Class::Inspector;
     my $cond = shift;
     my $attrs = shift || {};
     $attrs->{order_by} = 'year DESC';
-    $self->next::method($cond, $attrs);
+    $self->search($cond, $attrs);
   }
 
   $rs = $schema->resultset('CD')->search_by_year_desc({ artist => 'Tool' });
index eb58dd5..29e17e7 100644 (file)
@@ -292,13 +292,24 @@ constraint.
     constraint_name => [ qw/column1 column2/ ],
   );
 
+Alternatively, you can specify only the columns:
+
+  __PACKAGE__->add_unique_constraint([ qw/column1 column2/ ]);
+
+This will result in a unique constraint named C<table_column1_column2>, where
+C<table> is replaced with the table name.
+
 Unique constraints are used, for example, when you call
 L<DBIx::Class::ResultSet/find>. Only columns in the constraint are searched.
 
 =cut
 
 sub add_unique_constraint {
-  my ($self, $name, $cols) = @_;
+  my $self = shift;
+  my $cols = pop @_;
+  my $name = shift;
+
+  $name ||= $self->name_unique_constraint($cols);
 
   foreach my $col (@$cols) {
     $self->throw_exception("No such column $col on table " . $self->name)
@@ -310,6 +321,22 @@ sub add_unique_constraint {
   $self->_unique_constraints(\%unique_constraints);
 }
 
+=head2 name_unique_constraint
+
+Return a name for a unique constraint containing the specified columns. These
+names consist of the table name and each column name, separated by underscores.
+
+For example, a constraint on a table named C<cd> containing the columns
+C<artist> and C<title> would result in a constraint name of C<cd_artist_title>.
+
+=cut
+
+sub name_unique_constraint {
+  my ($self, $cols) = @_;
+
+  return join '_', $self->name, @$cols;
+}
+
 =head2 unique_constraints
 
 Read-only accessor which returns the list of unique constraints on this source.
index 98387b4..a38572c 100644 (file)
@@ -522,12 +522,11 @@ exception) an exception is thrown that includes a "Rollback failed" message.
 For example,
 
   my $author_rs = $schema->resultset('Author')->find(1);
+  my @titles = qw/Night Day It/;
 
   my $coderef = sub {
-    my ($author, @titles) = @_;
-
     # If any one of these fails, the entire transaction fails
-    $author->create_related('books', {
+    $author_rs->create_related('books', {
       title => $_
     }) foreach (@titles);
 
@@ -536,16 +535,14 @@ For example,
 
   my $rs;
   eval {
-    $rs = $schema->txn_do($coderef, $author_rs, qw/Night Day It/);
+    $rs = $schema->txn_do($coderef);
   };
 
-  if ($@) {
-    my $error = $@;
-    if ($error =~ /Rollback failed/) {
-      die "something terrible has happened!";
-    } else {
-      deal_with_failed_transaction();
-    }
+  if ($@) {                                  # Transaction failed
+    die "something terrible has happened!"   #
+      if ($@ =~ /Rollback failed/);          # Rollback failed
+
+    deal_with_failed_transaction();
   }
 
 In a nested transaction (calling txn_do() from within a txn_do() coderef) only
index 3f3f49c..46ac1cb 100644 (file)
@@ -297,6 +297,24 @@ C<quote_char>, and C<name_sep>.  Examples:
 
 Executes the sql statements given as a listref on every db connect.
 
+=head2 quote_char
+
+Specifies what characters to use to quote table and column names. If 
+you use this you will want to specify L<name_sep> as well.
+
+quote_char expectes either a single character, in which case is it is placed
+on either side of the table/column, or an array of length 2 in which case the
+table/column name is placed between the elements.
+
+For example under MySQL you'd use C<quote_char('`')>, and user SQL Server you'd 
+use C<quote_char(qw/[ ]/)>.
+
+=head2 name_sep
+
+This only needs to be used in conjunction with L<quote_char>, and is used to 
+specify the charecter that seperates elements (schemas, tables, columns) from 
+each other. In most cases this is simply a C<.>.
+
 =head2 debug
 
 Causes SQL trace information to be emitted on the C<debugobj> object.
@@ -509,8 +527,8 @@ Issues a commit against the current dbh.
 
 sub txn_commit {
   my $self = shift;
+  my $dbh = $self->dbh;
   if ($self->{transaction_depth} == 0) {
-    my $dbh = $self->dbh;
     unless ($dbh->{AutoCommit}) {
       $self->debugobj->txn_commit()
         if ($self->debug);
@@ -521,7 +539,7 @@ sub txn_commit {
     if (--$self->{transaction_depth} == 0) {
       $self->debugobj->txn_commit()
         if ($self->debug);
-      $self->dbh->commit;
+      $dbh->commit;
     }
   }
 }
@@ -538,8 +556,8 @@ sub txn_rollback {
   my $self = shift;
 
   eval {
+    my $dbh = $self->dbh;
     if ($self->{transaction_depth} == 0) {
-      my $dbh = $self->dbh;
       unless ($dbh->{AutoCommit}) {
         $self->debugobj->txn_rollback()
           if ($self->debug);
@@ -550,7 +568,7 @@ sub txn_rollback {
       if (--$self->{transaction_depth} == 0) {
         $self->debugobj->txn_rollback()
           if ($self->debug);
-        $self->dbh->rollback;
+        $dbh->rollback;
       }
       else {
         die DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION->new;
@@ -578,9 +596,10 @@ sub _execute {
   my $sth = eval { $self->sth($sql,$op) };
 
   if (!$sth || $@) {
-    $self->throw_exception('no sth generated via sql (' . ($@ || $self->_dbh->errstr) . "): $sql");
+    $self->throw_exception(
+      'no sth generated via sql (' . ($@ || $self->_dbh->errstr) . "): $sql"
+    );
   }
-
   @bind = map { ref $_ ? ''.$_ : $_ } @bind; # stringify args
   my $rv;
   if ($sth) {
@@ -841,6 +860,21 @@ sub deploy {
   }
 }
 
+sub datetime_parser {
+  my $self = shift;
+  return $self->{datetime_parser} ||= $self->build_datetime_parser(@_);
+}
+
+sub datetime_parser_type { "DateTime::Format::MySQL"; }
+
+sub build_datetime_parser {
+  my $self = shift;
+  my $type = $self->datetime_parser_type(@_);
+  eval "use ${type}";
+  $self->throw_exception("Couldn't load ${type}: $@") if $@;
+  return $type;
+}
+
 sub DESTROY { shift->disconnect }
 
 1;
index 83e2bc7..8e867e0 100644 (file)
@@ -21,6 +21,8 @@ sub last_insert_id
                          
 }
 
+sub datetime_parser_type { "DateTime::Format::DB2"; }
+
 1;
 
 =head1 NAME
index 171c17a..a303d25 100644 (file)
@@ -11,6 +11,14 @@ sub last_insert_id {
   my( $id ) = $_[0]->_dbh->selectrow_array('SELECT @@IDENTITY' );
   return $id;
 }
+
+sub build_datetime_parser {
+  my $self = shift;
+  my $type = "DateTime::Format::Strptime";
+  eval "use ${type}";
+  $self->throw_exception("Couldn't load ${type}: $@") if $@;
+  return $type->new( pattern => '%m/%d/%Y %H:%M:%S' );
+}
 \r
 1;
 \r
diff --git a/lib/DBIx/Class/Storage/DBI/ODBC400.pm b/lib/DBIx/Class/Storage/DBI/ODBC400.pm
new file mode 100644 (file)
index 0000000..7fdd1f8
--- /dev/null
@@ -0,0 +1,55 @@
+package DBIx::Class::Storage::DBI::ODBC400;
+use strict;
+use warnings;
+
+use base qw/DBIx::Class::Storage::DBI/;
+
+sub last_insert_id
+{
+    my ($self) = @_;
+
+    my $dbh = $self->_dbh;
+
+    # get the schema/table separator:
+    #    '.' when SQL naming is active
+    #    '/' when system naming is active
+    my $sep = $dbh->get_info(41);
+    my $sth = $dbh->prepare_cached(
+        "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM${sep}SYSDUMMY1", {}, 3);
+    $sth->execute();
+
+    my @res = $sth->fetchrow_array();
+
+    return @res ? $res[0] : undef;
+}
+
+1;
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::ODBC400 - Automatic primary key class for DB2/400
+over ODBC
+
+=head1 SYNOPSIS
+
+  # In your table classes
+  __PACKAGE__->load_components(qw/PK::Auto Core/);
+  __PACKAGE__->set_primary_key('id');
+
+
+=head1 DESCRIPTION
+
+This class implements autoincrements for DB2/400 over ODBC.
+
+
+=head1 AUTHORS
+
+Marc Mims C<< <marc@questright.com> >>
+
+Based on DBIx::Class::Storage::DBI::DB2 by Jess Robinson.
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut
index 526abac..aecaa7e 100644 (file)
@@ -7,6 +7,10 @@ use base qw/DBIx::Class::Storage::DBI/;
 
 # __PACKAGE__->load_components(qw/PK::Auto/);
 
+# Warn about problematic versions of DBD::Pg
+warn "DBD::Pg 1.49 is strongly recommended"
+  if ($DBD::Pg::VERSION < 1.49);
+
 sub last_insert_id {
   my ($self,$source,$col) = @_;
   my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
@@ -35,6 +39,8 @@ sub sqlt_type {
   return 'PostgreSQL';
 }
 
+sub datetime_parser_type { return "DateTime::Format::Pg"; }
+
 1;
 
 =head1 NAME
index 7a85075..be18f2d 100644 (file)
@@ -1,4 +1,6 @@
 use strict;
+use warnings;
+
 use Test::More;
 use IO::File;
 
@@ -6,14 +8,13 @@ BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 7 );
+        : ( tests => 6 );
 }
 
 use lib qw(t/lib);
 
 use_ok('DBICTest');
-
-use_ok('DBICTest::HelperRels');
+DBICTest->init_schema();
 
 DBICTest->schema->storage->sql_maker->quote_char("'");
 DBICTest->schema->storage->sql_maker->name_sep('.');
index 6904fdc..ddb4a00 100644 (file)
@@ -10,27 +10,30 @@ use lib qw(t/lib);
 BEGIN {
     eval "use DBD::SQLite";
     plan $ENV{DATA_DUMPER_TEST}
-        ? ( tests => 3 )
+        ? ( tests => 2 )
         : ( skip_all => 'Set $ENV{DATA_DUMPER_TEST} to run this test' );
 }
 
 
 use_ok('DBICTest');
-use_ok('DBICTest::HelperRels');
 
-
-my $rs = DBICTest::CD->search(
-           { 'artist.name' => 'We Are Goth',
-             'liner_notes.notes' => 'Kill Yourself!' },
-           { join => [ qw/artist liner_notes/ ] });
+my $schema = DBICTest->init_schema();
+my $rs = $schema->resultset('CD')->search({
+  'artist.name' => 'We Are Goth',
+  'liner_notes.notes' => 'Kill Yourself!',
+}, {
+  join => [ qw/artist liner_notes/ ],
+});
 
 Dumper($rs);
 
-$rs = DBICTest::CD->search(
-           { 'artist.name' => 'We Are Goth',
-             'liner_notes.notes' => 'Kill Yourself!' },
-           { join => [ qw/artist liner_notes/ ] });
+$rs = $schema->resultset('CD')->search({
+  'artist.name' => 'We Are Goth',
+  'liner_notes.notes' => 'Kill Yourself!',
+}, {
+  join => [ qw/artist liner_notes/ ],
+});
 
-cmp_ok( $rs + 0, '==', 1, "Single record in after death with dumper");
+cmp_ok( $rs->count(), '==', 1, "Single record in after death with dumper");
 
 1;
index a478d28..59aeb9e 100644 (file)
@@ -8,13 +8,13 @@ BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 13 );
+        : ( tests => 12 );
 }
 
 use lib qw(t/lib);
 
 use_ok('DBICTest');
-use_ok('DBICTest::HelperRels');
+DBICTest->init_schema();
 
 my $cbworks = 0;
 
diff --git a/t/53delete_related.t b/t/53delete_related.t
new file mode 100644 (file)
index 0000000..e0cfe12
--- /dev/null
@@ -0,0 +1,30 @@
+use Test::More;
+use strict;
+use warnings;
+use lib qw(t/lib);
+use DBICTest;
+
+plan tests => 7;
+
+my $schema = DBICTest->init_schema();
+my $total_cds = $schema->resultset('CD')->count;
+cmp_ok($total_cds, '>', 0, 'need cd records');
+
+# test that delete_related w/o conditions deletes all related records only
+my $artist = $schema->resultset("Artist")->find(3);
+my $artist_cds = $artist->cds->count;
+cmp_ok($artist_cds, '<', $total_cds, 'need more cds than just related cds');
+
+ok($artist->delete_related('cds'));
+cmp_ok($schema->resultset('CD')->count, '==', ($total_cds - $artist_cds), 'too many cds were deleted');
+
+$total_cds -= $artist_cds;
+
+# test that delete_related w/conditions deletes just the matched related records only
+my $artist2 = $schema->resultset("Artist")->find(2);
+my $artist2_cds = $artist2->search_related('cds')->count;
+cmp_ok($artist2_cds, '<', $total_cds, 'need more cds than related cds');
+
+ok($artist2->delete_related('cds', {title => {like => '%'}}));
+cmp_ok($schema->resultset('CD')->count, '==', ($total_cds - $artist2_cds), 'too many cds were deleted');
+
similarity index 93%
rename from t/run/01core.tl
rename to t/60core.t
index 05e4dd3..6ac90c7 100644 (file)
@@ -1,7 +1,13 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
 
-plan tests => 58;
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 60;
 
 # figure out if we've got a version of sqlite that is older than 3.2.6, in
 # which case COUNT(DISTINCT()) doesn't work
@@ -32,6 +38,14 @@ is($art->get_column("name"), 'We Are In Rehab', 'And via get_column');
 
 ok($art->update, 'Update run');
 
+my $record_jp = $schema->resultset("Artist")->search(undef, { join => 'cds' })->search(undef, { prefetch => 'cds' })->next;
+
+ok($record_jp, "prefetch on same rel okay");
+
+my $record_fn = $schema->resultset("Artist")->search(undef, { join => 'cds' })->search({'cds.cdid' => '1'}, {join => 'artist_undirected_maps'})->next;
+
+ok($record_fn, "funny join is okay");
+
 @art = $schema->resultset("Artist")->search({ name => 'We Are In Rehab' });
 
 cmp_ok(@art, '==', 1, "Changed artist returned by search");
@@ -80,7 +94,7 @@ $new->name('Man With A Spoon');
 
 $new->update;
 
-$new_again = $schema->resultset("Artist")->find(4);
+my $new_again = $schema->resultset("Artist")->find(4);
 
 is($new_again->name, 'Man With A Spoon', 'Retrieved correctly');
 
@@ -270,6 +284,3 @@ ok(!$@, "stringify to false value doesn't cause error");
   is_deeply([$schema->source('CD')->columns], [qw/cdid artist title/]);
 }
 
-}
-
-1;
similarity index 91%
rename from t/run/04db.tl
rename to t/64db.t
index 4865d96..d9c03aa 100644 (file)
+++ b/t/64db.t
@@ -1,6 +1,12 @@
-sub run_tests {
-my $schema = shift;
-  
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
 plan tests => 3;
 
 # add some rows inside a transaction and commit it
@@ -48,6 +54,3 @@ my $test_type_info = {
 };
 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 
-}
-
-1;
similarity index 56%
rename from t/run/05multipk.tl
rename to t/65multipk.t
index e60f006..084bb8e 100644 (file)
@@ -1,13 +1,19 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
 
-plan tests => 4;
-$artist = DBICTest::Artist->find(1);
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 5;
+
+my $artist = DBICTest::Artist->find(1);
 ok($artist->find_related('twokeys', {cd => 1}), "find multiple pks using relationships + args");
+
+ok($schema->resultset("FourKeys")->search({ foo => 1, bar => 2 })->find({ hello => 3, goodbye => 4 }), "search on partial key followed by a find");
 ok($schema->resultset("FourKeys")->find(1,2,3,4), "find multiple pks without hash");
 ok($schema->resultset("FourKeys")->find(5,4,3,6), "find multiple pks without hash");
 is($schema->resultset("FourKeys")->find(1,2,3,4)->ID, 'DBICTest::FourKeys|fourkeys|bar=2|foo=1|goodbye=4|hello=3', 'unique object id ok for multiple pks');
 
-}
-
-1;
similarity index 93%
rename from t/run/06relationship.tl
rename to t/66relationship.t
index a66211e..dce68f7 100644 (file)
@@ -1,8 +1,12 @@
-sub run_tests {
-my $schema = shift;
-
 use strict;
 use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
 plan tests => 32;
 
 # has_a test
@@ -56,11 +60,7 @@ my $track = $schema->resultset("Track")->create( {
 } );
 $track->set_from_related( cd => $cd );
 
-if ($INC{'DBICTest/HelperRels.pm'}) { # expect inflated object
-  is($track->disc->cdid, 4, 'set_from_related ok, including alternative accessor' );
-} else {
-  is( $track->cd, 4, 'set_from_related ok' );
-}
+is($track->disc->cdid, 4, 'set_from_related ok, including alternative accessor' );
 
 $track->set_from_related( cd => undef );
 
@@ -78,11 +78,7 @@ $track->update_from_related( cd => $cd );
 
 my $t_cd = ($schema->resultset("Track")->search( cd => 4, position => 99 ))[0]->cd;
 
-if ($INC{'DBICTest/HelperRels.pm'}) { # except inflated object
-  is( $t_cd->cdid, 4, 'update_from_related ok' );
-} else {
-  is( $t_cd, 4, 'update_from_related ok' );
-}
+is( $t_cd->cdid, 4, 'update_from_related ok' );
 
 # find_or_create_related with an existing record
 $cd = $artist->find_or_create_related( 'cds', { title => 'Big Flop' } );
@@ -170,6 +166,3 @@ $artist->cds->update({artist => $nartist->id});
 cmp_ok($artist->cds->count, '==', 0, "Correct new #cds for artist");
 cmp_ok($nartist->cds->count, '==', 2, "Correct new #cds for artist");
 
-}
-
-1;
similarity index 92%
rename from t/run/07pager.tl
rename to t/67pager.t
index d864afa..267927d 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 plan tests => 12;
 
@@ -62,6 +68,3 @@ is( $it->count, 2, "software count on paged rs ok" );
 
 is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" );
 
-}
-
-1;
similarity index 84%
rename from t/run/08inflate.tl
rename to t/68inflate.t
index e21a6c6..b730253 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 eval { require DateTime };
 plan skip_all => "Need DateTime for inflation tests" if $@;
@@ -27,6 +33,3 @@ $cd->update;
 ($cd) = $schema->resultset("CD")->search( year => $now->year );
 is( $cd->year->year, $now->year, 'deflate ok' );
 
-}
-
-1;
similarity index 91%
rename from t/run/08inflate_has_a.tl
rename to t/68inflate_has_a.t
index 50f78c4..1346ce5 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 eval { require DateTime };
 plan skip_all => "Need DateTime for inflation tests" if $@;
@@ -50,6 +56,3 @@ $cd->update;
 ($cd) = $schema->resultset("CD")->search( year => $now->year );
 is( $cd->year->year, $now->year, 'deflate ok' );
 
-}
-
-1;
similarity index 93%
rename from t/run/08inflate_serialize.tl
rename to t/68inflate_serialize.t
index ae5ca7a..5eed843 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 use Data::Dumper;
 
@@ -67,6 +73,3 @@ ok($entry->update ({ %{$complex2} }), 'arrayref deflation ok');
 ok($inflated = $entry->serialized, 'arrayref inflation ok');
 is_deeply($inflated, $complex2->{serialized}, 'inflated array matches original');
 
-}
-
-1;
similarity index 83%
rename from t/run/09update.tl
rename to t/69update.t
index ff802f0..3372b4f 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 BEGIN {
         eval "use DBD::SQLite";
@@ -21,6 +27,3 @@ ok($art->name($name) eq $name, 'update');
 
 $art->discard_changes;
 
-}
-
-1;
similarity index 81%
rename from t/run/10auto.tl
rename to t/70auto.t
index 7c795f4..440c943 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 plan tests => 2;
 
@@ -14,6 +20,3 @@ ok($artist->update, 'update on object created without PK ok');
 my $copied = $artist->copy({ name => 'Don\'t tell the RIAA', artistid => undef });
 is($copied->name, 'Don\'t tell the RIAA', "Copied with PKs ok.");
 
-}
-
-1;
similarity index 91%
rename from t/run/11mysql.tl
rename to t/71mysql.t
index 15664d9..93f45fd 100644 (file)
@@ -1,11 +1,15 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
 
 #warn "$dsn $user $pass";
 
-plan skip_all, 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
+plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
 plan tests => 5;
@@ -71,6 +75,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 # clean up our mess
 $dbh->do("DROP TABLE artist");
 
-}
-
-1;
similarity index 79%
rename from t/run/12pg.tl
rename to t/72pg.t
index 5432a60..f0bb3f8 100644 (file)
+++ b/t/72pg.t
@@ -1,20 +1,39 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+{
+  package DBICTest::Schema::Casecheck;
+
+  use strict;
+  use warnings;
+  use base 'DBIx::Class';
+
+  __PACKAGE__->load_components(qw/PK::Auto Core/);
+  __PACKAGE__->table('casecheck');
+  __PACKAGE__->add_columns(qw/id name NAME uc_name/);
+  __PACKAGE__->set_primary_key('id');
+
+}
+
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
 
 #warn "$dsn $user $pass";
 
-plan skip_all, 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
-  . ' (note: creates and drops tables named artist and casecheck!)' unless ($dsn && $user);
+plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
+ . ' (note: creates and drops tables named artist and casecheck!)' unless ($dsn && $user);
 
 plan tests => 8;
 
+DBICTest::Schema->load_classes( 'Casecheck' );
 DBICTest::Schema->compose_connection('PgTest' => $dsn, $user, $pass);
 
 my $dbh = PgTest->schema->storage->dbh;
 PgTest->schema->source("Artist")->name("testschema.artist");
 $dbh->do("CREATE SCHEMA testschema;");
-
 $dbh->do("CREATE TABLE testschema.artist (artistid serial PRIMARY KEY, name VARCHAR(100), charfield CHAR(10));");
 ok ( $dbh->do('CREATE TABLE testschema.casecheck (id serial PRIMARY KEY, "name" VARCHAR(1), "NAME" VARCHAR(2), "UC_NAME" VARCHAR(3));'), 'Creation of casecheck table');
 
@@ -70,6 +89,3 @@ $dbh->do("DROP TABLE testschema.artist;");
 $dbh->do("DROP TABLE testschema.casecheck;");
 $dbh->do("DROP SCHEMA testschema;");
 
-}
-
-1;
similarity index 91%
rename from t/run/13oracle.tl
rename to t/73oracle.t
index f38b767..c0489ff 100644 (file)
@@ -1,9 +1,13 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/};
 
-plan skip_all, 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' .
+plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' .
   'Warning: This test drops and creates tables called \'artist\', \'cd\' and \'track\''
   unless ($dsn && $user && $pass);
 
@@ -61,8 +65,8 @@ my $other_track = OraTest::Track->create({ trackid => 2, cd => 1, position => 1,
 my $tcount = OraTest::Track->search(
     {},
     {
-       select => [{count => {distinct => ['position', 'title']}}],
-       as => ['count']
+        select => [{count => {distinct => ['position', 'title']}}],
+        as => ['count']
     }
   );
 
@@ -89,6 +93,3 @@ $dbh->do("DROP TABLE artist");
 $dbh->do("DROP TABLE cd");
 $dbh->do("DROP TABLE track");
 
-}
-
-1;
similarity index 91%
rename from t/run/145db2.tl
rename to t/745db2.t
index 31e3461..ffb7a0b 100644 (file)
@@ -1,11 +1,15 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/};
 
 #warn "$dsn $user $pass";
 
-plan skip_all, 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test'
+plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
 plan tests => 6;
@@ -68,6 +72,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 # clean up our mess
 $dbh->do("DROP TABLE artist");
 
-}
-
-1;
similarity index 91%
rename from t/run/146db2_400.tl
rename to t/746db2_400.t
index ac6cd47..558ca62 100644 (file)
@@ -1,5 +1,9 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/};
 
@@ -8,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/
 # Probably best to pass the DBQ option in the DSN to specify a specific
 # libray.  Something like:
 # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB'
-plan skip_all, 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test'
+plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
 plan tests => 6;
@@ -69,6 +73,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 # clean up our mess
 $dbh->do("DROP TABLE artist");
 
-}
-
-1;
similarity index 79%
rename from t/run/14mssql.tl
rename to t/74mssql.t
index befc14d..c879ca6 100644 (file)
@@ -1,16 +1,20 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
 
 #warn "$dsn $user $pass";
 
-plan skip_all, 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
+plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
   unless ($dsn);
 
 plan tests => 4;
 
-$schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass );
+DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass );
 
 my $dbh = MSSQLTest->schema->storage->dbh;
 
@@ -43,6 +47,3 @@ $it->next;
 $it->next;
 is( $it->next, undef, "next past end of resultset ok" );
 
-}
-
-1;
similarity index 93%
rename from t/run/15limit.tl
rename to t/75limit.t
index eca720d..0fc7e3a 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 BEGIN {
     eval "use DBD::SQLite";
@@ -62,6 +68,3 @@ $it = $schema->resultset("CD")->search(
 );
 is( $it->count, 1, "complex abstract count ok" );
 
-}
-
-1;
similarity index 92%
rename from t/run/16joins.tl
rename to t/76joins.t
index 15603aa..c697254 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 use IO::File;
 
@@ -7,7 +13,7 @@ BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 44 );
+        : ( tests => 42 );
 }
 
 # figure out if we've got a version of sqlite that is older than 3.2.6, in
@@ -101,10 +107,6 @@ $rs = $schema->resultset("CD")->search(
 );
 cmp_ok( scalar $rs->all, '==', scalar $rs->slice(0, $rs->count - 1), 'slice() with join has same count as all()' );
 
-eval { $rs->search(undef, { rows => 0, offset => 3 })->all; };
-
-ok($@, "rows => 0 errors: $@");
-
 $rs = $schema->resultset("Artist")->search(
         { 'liner_notes.notes' => 'Kill Yourself!' },
         { join => { 'cds' => 'liner_notes' } });
@@ -277,25 +279,3 @@ $schema->storage->debug(0);
 
 cmp_ok($queries, '==', 1, 'Only one query run');
 
-# has_many resulting in an additional select if no records available despite prefetch
-my $track = $schema->resultset("Artist")->create( {
-  artistid  => 4,
-  name      => 'Artist without CDs',
-} );
-
-$queries = 0;
-$schema->storage->debug(1);
-
-my $artist_without_cds = $schema->resultset("Artist")->find(4, {
-    join        => [qw/ cds /],
-    prefetch    => [qw/ cds /],
-});
-my @no_cds = $artist_without_cds->cds;
-
-is($queries, 1, 'prefetch ran only 1 sql statement');
-
-$schema->storage->debug(0);
-
-} # end run_tests
-
-1;
similarity index 87%
rename from t/run/17join_count.tl
rename to t/77join_count.t
index 08335e0..f46ad04 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 eval "use DBD::SQLite";
 plan skip_all => 'needs DBD::SQLite for testing' if $@;
@@ -23,6 +29,3 @@ cmp_ok($schema->resultset("CD")->count(
            { join => [ qw/tags liner_notes/ ] } ),
            '==', 2, "Mixed count ok");
 
-}
-
-1;
similarity index 88%
rename from t/run/18self_referencial.tl
rename to t/78self_referencial.t
index b061adb..640cbc2 100644 (file)
@@ -1,39 +1,42 @@
-sub run_tests {
-my $schema = shift;\r
-\r
-# this test will check to see if you can have 2 columns\r
-# in the same class pointing at the same other class\r
-#\r
-# example:\r
-#\r
-# +---------+       +--------------+\r
-# | SelfRef |       | SelfRefAlias |\r
-# +---------+  1-M  +--------------+\r
-# | id      |-------| self_ref     | --+\r
-# | name    |       | alias        | --+\r
-# +---------+       +--------------+   |\r
-#    /|\                               |\r
-#     |                                |\r
-#     +--------------------------------+\r
-#\r
-# see http://use.perl.org/~LTjake/journal/24876 for the\r
-# issue with CDBI\r
-\r
-plan tests => 4;\r
-\r
-my $item = $schema->resultset("SelfRef")->find( 1 );\r
-is( $item->name, 'First', 'proper start item' );\r
-\r
-my @aliases = $item->aliases;\r
-\r
-is( scalar @aliases, 1, 'proper number of aliases' );\r
-\r
-my $orig  = $aliases[ 0 ]->self_ref;\r
-my $alias = $aliases[ 0 ]->alias;\r
-\r
-is( $orig->name, 'First', 'proper original' );\r
-is( $alias->name, 'Second', 'proper alias' );\r
-\r
-}\r
-\r
-1;\r
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+# this test will check to see if you can have 2 columns
+# in the same class pointing at the same other class
+#
+# example:
+#
+# +---------+       +--------------+
+# | SelfRef |       | SelfRefAlias |
+# +---------+  1-M  +--------------+
+# | id      |-------| self_ref     | --+
+# | name    |       | alias        | --+
+# +---------+       +--------------+   |
+#    /|\                               |
+#     |                                |
+#     +--------------------------------+
+#
+# see http://use.perl.org/~LTjake/journal/24876 for the
+# issue with CDBI
+
+plan tests => 4;
+
+my $item = $schema->resultset("SelfRef")->find( 1 );
+is( $item->name, 'First', 'proper start item' );
+
+my @aliases = $item->aliases;
+
+is( scalar @aliases, 1, 'proper number of aliases' );
+
+my $orig  = $aliases[ 0 ]->self_ref;
+my $alias = $aliases[ 0 ]->alias;
+
+is( $orig->name, 'First', 'proper original' );
+is( $alias->name, 'Second', 'proper alias' );
+
similarity index 64%
rename from t/run/19uuid.tl
rename to t/79uuid.t
index 0da87f1..1a3061d 100644 (file)
@@ -1,8 +1,14 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 eval 'use Data::UUID ; 1'
-  or plan skip_all, 'Install Data::UUID run this test';
+  or plan skip_all => 'Install Data::UUID run this test';
 
 plan tests => 1;
 DBICTest::Schema::Artist->load_components('UUIDColumns');
@@ -12,6 +18,3 @@ Class::C3->reinitialize();
 my $artist = $schema->resultset("Artist")->create( { artistid => 100 } );
 like $artist->name, qr/[\w-]{36}/, 'got something like uuid';
 
-}
-
-1;
similarity index 84%
rename from t/run/20unique.tl
rename to t/80unique.t
index 19481ef..18a41f2 100644 (file)
@@ -1,7 +1,16 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
 
-plan tests => 34;
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 36;
+
+is_deeply([ sort $schema->source('CD')->unique_constraint_names ], [ qw/cd_artist_title primary/ ], 'CD source has an automatically named unique constraint');
+is_deeply([ sort $schema->source('Producer')->unique_constraint_names ], [ qw/primary prod_name/ ], 'Producer source has a named unique constraint');
 
 my $artistid = 1;
 my $title    = 'UNIQUE Constraint';
@@ -17,14 +26,14 @@ my $cd2 = $schema->resultset('CD')->find(
     artist => $artistid,
     title  => $title,
   },
-  { key => 'artist_title' }
+  { key => 'cd_artist_title' }
 );
 
 is($cd2->get_column('artist'), $cd1->get_column('artist'), 'find by specific key: artist is correct');
 is($cd2->title, $cd1->title, 'title is correct');
 is($cd2->year, $cd1->year, 'year is correct');
 
-my $cd3 = $schema->resultset('CD')->find($artistid, $title, { key => 'artist_title' });
+my $cd3 = $schema->resultset('CD')->find($artistid, $title, { key => 'cd_artist_title' });
 
 is($cd3->get_column('artist'), $cd1->get_column('artist'), 'find by specific key, ordered columns: artist is correct');
 is($cd3->title, $cd1->title, 'title is correct');
@@ -50,7 +59,7 @@ my $cd5 = $schema->resultset('CD')->update_or_create(
     title  => $title,
     year   => 2007,
   },
-  { key => 'artist_title' }
+  { key => 'cd_artist_title' }
 );
 
 ok(! $cd5->is_changed, 'update_or_create by specific key: row is clean');
@@ -81,7 +90,7 @@ my $cd7 = $schema->resultset('CD')->find_or_create(
     title  => $title,
     year   => 2010,
   },
-  { key => 'artist_title' }
+  { key => 'cd_artist_title' }
 );
 
 is($cd7->cdid, $cd1->cdid, 'find_or_create by specific key: cdid is correct');
@@ -92,11 +101,10 @@ is($cd7->year, $cd1->year, 'year is correct');
 my $artist = $schema->resultset('Artist')->find($artistid);
 my $cd8 = $artist->find_or_create_related('cds',
   {
-    artist => $artistid,
     title  => $title,
     year   => 2020,
   },
-  { key => 'artist_title' }
+  { key => 'cd_artist_title' }
 );
 
 is($cd8->cdid, $cd1->cdid, 'find_or_create related by specific key: cdid is correct');
@@ -106,11 +114,10 @@ is($cd8->year, $cd1->year, 'year is correct');
 
 my $cd9 = $artist->update_or_create_related('cds',
   {
-    artist => $artistid,
     title  => $title,
     year   => 2021,
   },
-  { key => 'artist_title' }
+  { key => 'cd_artist_title' }
 );
 
 ok(! $cd9->is_changed, 'update_or_create by specific key: row is clean');
@@ -119,6 +126,3 @@ is($cd9->get_column('artist'), $cd1->get_column('artist'), 'artist is correct');
 is($cd9->title, $cd1->title, 'title is correct');
 is($cd9->year, 2021, 'year is correct');
 
-}
-
-1;
similarity index 97%
rename from t/run/21transactions.tl
rename to t/81transactions.t
index eafc575..847963e 100644 (file)
@@ -1,5 +1,12 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
 plan tests => 39;
 
 my $code = sub {
@@ -110,6 +117,7 @@ my $fail_code = sub {
 
   # Force txn_rollback() to throw an exception
   no warnings 'redefine';
+  no strict 'refs';
   local *{"DBIx::Class::Schema::txn_rollback"} = sub{die 'FAILED'};
 
   eval {
@@ -169,6 +177,4 @@ my $fail_code = sub {
   })->first;
   ok(!defined($cd), q{failed txn_do didn't add failed txn's cd});
 }
-}
 
-1;
similarity index 84%
rename from t/run/22cascade_copy.tl
rename to t/82cascade_copy.t
index 82642f2..26b8425 100644 (file)
@@ -1,8 +1,11 @@
 use strict;
-use warnings;
+use warnings;  
 
-sub run_tests {
-my $schema = shift;
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 plan tests => 4;
 my $artist = $schema->resultset('Artist')->find(1);
@@ -11,7 +14,7 @@ my $artist_cds = $artist->search_related('cds');
 my $cover_band;
 
 {
-  no warnings 'redefine';
+  no warnings qw(redefine once);
   local *DBICTest::Artist::result_source_instance = \&DBICTest::Schema::Artist::result_source_instance;
 
   $cover_band = $artist->copy;
@@ -28,5 +31,3 @@ cmp_ok($cover_band->search_related('twokeys')->count, '>', 0, 'duplicated multiP
 cmp_ok($cover_cds->search_related('tags')->count, '==',
    $artist_cds->search_related('tags')->count , 'duplicated count ok');
 
-}
-1;
similarity index 96%
rename from t/run/23cache.tl
rename to t/83cache.t
index a822601..78113b3 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 my $queries;
 $schema->storage->debugcb( sub{ $queries++ } );
@@ -34,7 +40,7 @@ $rs->set_cache( $artists );
 
 is( scalar @{$rs->get_cache}, 2, 'set_cache() is functional' );
 
-$cd = $schema->resultset('CD')->find(1);
+my $cd = $schema->resultset('CD')->find(1);
 
 $rs->clear_cache;
 
@@ -173,6 +179,3 @@ is( $queries, 1, 'only one select statement on find with has_many prefetch on re
 
 $schema->storage->debug(0);
 
-}
-
-1;
similarity index 62%
rename from t/run/24serialize.tl
rename to t/84serialize.t
index 7c746f2..a8cedf0 100644 (file)
@@ -1,7 +1,12 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 use Storable;
 
-sub run_tests {
-my $schema = shift;
+my $schema = DBICTest->init_schema();
 
 plan tests => 1;
 
@@ -9,6 +14,3 @@ my $artist = $schema->resultset('Artist')->find(1);
 my $copy = eval { Storable::dclone($artist) };
 is_deeply($copy, $artist, 'serialize row object works');
 
-}
-
-1;
diff --git a/t/85utf8.t b/t/85utf8.t
new file mode 100644 (file)
index 0000000..562efb4
--- /dev/null
@@ -0,0 +1,27 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+eval 'use Encode ; 1'
+    or plan skip_all => 'Install Encode run this test';
+
+plan tests => 2;
+
+DBICTest::Schema::Artist->load_components('UTF8Columns');
+DBICTest::Schema::Artist->utf8_columns('name');
+Class::C3->reinitialize();
+
+my $artist = $schema->resultset("Artist")->create( { name => 'uni' } );
+ok( Encode::is_utf8( $artist->name ), 'got name with utf8 flag' );
+
+my $utf8_char = 'uniuni';
+Encode::_utf8_on($utf8_char);
+$artist->name($utf8_char);
+ok( !Encode::is_utf8( $artist->{_column_data}->{name} ),
+    'store utf8 less chars' );
+
similarity index 87%
rename from t/run/26might_have.tl
rename to t/86might_have.t
index 0b700e8..81cbf84 100644 (file)
@@ -1,5 +1,11 @@
-sub run_tests {
-my $schema = shift;
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
 
 my $queries;
 #$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w'));
@@ -38,6 +44,4 @@ is($queries, 1, 'liner_notes (might_have) prefetched - do not load
 liner_notes on update');
 
 $schema->storage->debug(0);
-}
 
-1;
similarity index 93%
rename from t/helperrels/26sqlt.t
rename to t/86sqlt.t
index af87625..1b80e21 100644 (file)
@@ -1,14 +1,16 @@
+use strict;
+use warnings;
+
 use Test::More;
 use lib qw(t/lib);
 use DBICTest;
-use DBICTest::HelperRels;
 
 eval "use SQL::Translator";
 plan skip_all => 'SQL::Translator required' if $@;
 
 # do not taunt happy dave ball
 
-my $schema = DBICTest::Schema;
+my $schema = 'DBICTest::Schema';
 
 plan tests => 33;
 
@@ -71,10 +73,14 @@ my @fk_constraints =
    'selftable' => 'treelike', 'foreigntable' => 'treelike', 
    'selfcols'  => ['parent'], 'foreigncols' => ['id'],
    'needed' => 1, on_delete => '', on_update => ''},
-  {'display' => 'twokeytreelike -> twokeytreelike for parent1,parent2',
-   'selftable' => 'twokeytreelike', 'foreigntable' => 'twokeytreelike', 
-   'selfcols'  => ['parent1', 'parent2'], 'foreigncols' => ['id1','id2'],
-   'needed' => 1, on_delete => '', on_update => ''},
+
+  # shouldn't this be generated?
+  # 
+  #{'display' => 'twokeytreelike -> twokeytreelike for parent1,parent2',
+  # 'selftable' => 'twokeytreelike', 'foreigntable' => 'twokeytreelike', 
+  # 'selfcols'  => ['parent1', 'parent2'], 'foreigncols' => ['id1','id2'],
+  # 'needed' => 1, on_delete => '', on_update => ''},
+
   {'display' => 'tags -> cd',
    'selftable' => 'tags', 'foreigntable' => 'cd', 
    'selfcols'  => ['cd'], 'foreigncols' => ['cdid'],
@@ -89,6 +95,9 @@ my @unique_constraints = (
   {'display' => 'cd artist and title unique',
    'table' => 'cd', 'cols' => ['artist', 'title'],
    'needed' => 1},
+  {'display' => 'producer name unique',
+   'table' => 'producer', 'cols' => ['name'],
+   'needed' => 1},
   {'display' => 'twokeytreelike name unique',
    'table' => 'twokeytreelike', 'cols'  => ['name'],
    'needed' => 1},
@@ -173,6 +182,8 @@ sub check_fk {
  return 0;
 }
 
+my( $ondel, $onupd );
+
 sub check_unique {
  my ($selftable, $selfcol) = @_;
 
similarity index 69%
rename from t/run/27ordered.tl
rename to t/87ordered.t
index 3a53951..b1d484c 100644 (file)
@@ -1,39 +1,40 @@
 # vim: filetype=perl
+use strict;
+use warnings;  
 
-sub run_tests {
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 
-    plan tests => 321;
-    my $schema = shift;
+my $schema = DBICTest->init_schema();
 
-    my $employees = $schema->resultset('Employee');
-    $employees->delete();
+plan tests => 321;
 
-    foreach (1..5) {
-        $employees->create({ name=>'temp' });
-    }
-    $employees = $employees->search(undef,{order_by=>'position'});
-    ok( check_rs($employees), "intial positions" );
-
-    hammer_rs( $employees );
+my $employees = $schema->resultset('Employee');
+$employees->delete();
 
-    #return;
+foreach (1..5) {
+    $employees->create({ name=>'temp' });
+}
+$employees = $employees->search(undef,{order_by=>'position'});
+ok( check_rs($employees), "intial positions" );
 
-    DBICTest::Employee->grouping_column('group_id');
-    $employees->delete();
-    foreach my $group_id (1..3) {
-        foreach (1..6) {
-            $employees->create({ name=>'temp', group_id=>$group_id });
-        }
-    }
-    $employees = $employees->search(undef,{order_by=>'group_id,position'});
+hammer_rs( $employees );
 
-    foreach my $group_id (1..3) {
-        my $group_employees = $employees->search({group_id=>$group_id});
-        $group_employees->all();
-        ok( check_rs($group_employees), "group intial positions" );
-        hammer_rs( $group_employees );
+DBICTest::Employee->grouping_column('group_id');
+$employees->delete();
+foreach my $group_id (1..3) {
+    foreach (1..6) {
+        $employees->create({ name=>'temp', group_id=>$group_id });
     }
+}
+$employees = $employees->search(undef,{order_by=>'group_id,position'});
 
+foreach my $group_id (1..3) {
+    my $group_employees = $employees->search({group_id=>$group_id});
+    $group_employees->all();
+    ok( check_rs($group_employees), "group intial positions" );
+    hammer_rs( $group_employees );
 }
 
 sub hammer_rs {
@@ -41,6 +42,7 @@ sub hammer_rs {
     my $employee;
     my $count = $rs->count();
     my $position_column = $rs->result_class->position_column();
+    my $row;
 
     foreach my $position (1..$count) {
 
@@ -101,4 +103,3 @@ sub check_rs {
     return 1;
 }
 
-1;
diff --git a/t/88result_set_column.t b/t/88result_set_column.t
new file mode 100644 (file)
index 0000000..936a0a7
--- /dev/null
@@ -0,0 +1,44 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 8; 
+
+my $cd;
+my $rs = $cd = $schema->resultset("CD")->search({});
+
+my $rs_title = $rs->get_column('title');
+my $rs_year = $rs->get_column('year');
+
+is($rs_title->next, 'Spoonful of bees', "next okay");
+
+my @all = $rs_title->all;
+cmp_ok(scalar @all, '==', 5, "five titles returned");
+
+cmp_ok($rs_year->max, '==', 2001, "max okay for year");
+is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title");
+
+cmp_ok($rs_year->sum, '==', 9996, "three artists returned");
+
+my $psrs = $schema->resultset('CD')->search({},
+    {
+        '+select'   => \'COUNT(*)',
+        '+as'       => 'count'
+    }
+);
+ok(defined($psrs->get_column('count')), '+select/+as count');
+
+$psrs = $schema->resultset('CD')->search({},
+    {
+        '+select'   => [ \'COUNT(*)', 'title' ],
+        '+as'       => [ 'count', 'addedtitle' ]
+    }
+);
+ok(defined($psrs->get_column('count')), '+select/+as arrayref count');
+ok(defined($psrs->get_column('addedtitle')), '+select/+as title');
+
diff --git a/t/89dbicadmin.t b/t/89dbicadmin.t
new file mode 100644 (file)
index 0000000..0b1d1f5
--- /dev/null
@@ -0,0 +1,41 @@
+# vim: filetype=perl
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+eval 'require JSON';
+plan skip_all => 'Install JSON to run this test' if ($@);
+
+eval 'require Text::CSV_XS';
+if ($@) {
+    eval 'require Text::CSV_PP';
+    plan skip_all => 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@);
+}
+
+plan tests => 5;
+
+my $employees = $schema->resultset('Employee');
+my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|;
+
+`$cmd --op=insert --set='{name:"Matt"}'`;
+ok( ($employees->count()==1), 'insert count' );
+
+my $employee = $employees->find(1);
+ok( ($employee->name() eq 'Matt'), 'insert valid' );
+
+`$cmd --op=update --set='{name:"Trout"}'`;
+$employee = $employees->find(1);
+ok( ($employee->name() eq 'Trout'), 'update' );
+
+`$cmd --op=insert --set='{name:"Aran"}'`;
+my $data = `$cmd --op=select --attrs='{order_by:"name"}'`;
+ok( ($data=~/Aran.*Trout/s), 'select with attrs' );
+
+`$cmd --op=delete --where='{name:"Trout"}'`;
+ok( ($employees->count()==1), 'delete' );
+
diff --git a/t/89inflate_datetime.t b/t/89inflate_datetime.t
new file mode 100644 (file)
index 0000000..254348a
--- /dev/null
@@ -0,0 +1,21 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+eval { require DateTime::Format::MySQL };
+plan skip_all => "Need DateTime::Format::MySQL for inflation tests" if $@;
+
+plan tests => 2;
+
+# inflation test
+my $event = $schema->resultset("Event")->find(1);
+
+isa_ok($event->starts_at, 'DateTime', 'DateTime returned');
+
+is($event->starts_at, '2006-04-25T22:24:33', 'Correct date/time');
+
similarity index 87%
rename from t/run/30ensure_class_loaded.tl
rename to t/90ensure_class_loaded.t
index 8602565..8f66c2e 100644 (file)
@@ -1,3 +1,9 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
 use Class::Inspector;
 
 BEGIN {
@@ -5,9 +11,8 @@ BEGIN {
   sub some_method {}
 }
 
-sub run_tests {
+my $schema = DBICTest->init_schema();
 
-my $schema = shift;
 plan tests => 6;
 
 ok(Class::Inspector->loaded('TestPackage::A'),
@@ -35,6 +40,5 @@ eval {
 ok(!$@, 'ensure_class_loaded detected an existing but non-loaded class');
 ok(Class::Inspector->loaded('DBICTest::FakeComponent'),
    'DBICTest::FakeComponent now loaded');
-}
 
 1;
diff --git a/t/90join_torture.t b/t/90join_torture.t
new file mode 100644 (file)
index 0000000..eb66445
--- /dev/null
@@ -0,0 +1,29 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 4;
+
+my $rs1 = $schema->resultset("Artist")->search({ 'tags.tag' => 'Blue' }, { join => {'cds' => 'tracks'}, prefetch => {'cds' => 'tags'} });
+my @artists = $rs1->all;
+cmp_ok(@artists, '==', 1, "Two artists returned");
+
+my $rs2 = $rs1->search({ artistid => '1' }, { join => {'cds' => {'cd_to_producer' => 'producer'} } });
+my $rs3 = $rs2->search_related('cds')->search({'cds.title' => 'Forkful of bees'});
+cmp_ok($rs3->count, '==', 3, "Three artists returned");
+
+my $rs4 = $schema->resultset("CD")->search({ 'artist.artistid' => '1' }, { join => ['tracks', 'artist'], prefetch => 'artist' });
+my @rs4_results = $rs4->all;
+
+
+is($rs4_results[0]->cdid, 1, "correct artist returned");
+
+my $rs5 = $rs4->search({'tracks.title' => 'Sticky Honey'});
+is($rs5->count, 1, "search without using previous joins okay");
+
+1;
diff --git a/t/basicrels/01core.t b/t/basicrels/01core.t
deleted file mode 100644 (file)
index ac97f9c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/01core.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/04db.t b/t/basicrels/04db.t
deleted file mode 100644 (file)
index 67aa083..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/04db.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/05multipk.t b/t/basicrels/05multipk.t
deleted file mode 100644 (file)
index 1bc84b3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/05multipk.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/06relationship.t b/t/basicrels/06relationship.t
deleted file mode 100644 (file)
index 04a9afb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/06relationship.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/07pager.t b/t/basicrels/07pager.t
deleted file mode 100644 (file)
index ff1a778..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/07pager.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/08inflate.t b/t/basicrels/08inflate.t
deleted file mode 100644 (file)
index e35bf0f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/08inflate.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/08inflate_has_a.t b/t/basicrels/08inflate_has_a.t
deleted file mode 100644 (file)
index 187b174..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/08inflate_has_a.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/08inflate_serialize.t b/t/basicrels/08inflate_serialize.t
deleted file mode 100644 (file)
index 3676643..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/08inflate_serialize.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/09update.t b/t/basicrels/09update.t
deleted file mode 100644 (file)
index 2b483ed..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/09update.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/10auto.t b/t/basicrels/10auto.t
deleted file mode 100644 (file)
index 6e7fffb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/10auto.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/11mysql.t b/t/basicrels/11mysql.t
deleted file mode 100644 (file)
index 4b3226b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/11mysql.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/12pg.t b/t/basicrels/12pg.t
deleted file mode 100644 (file)
index 1953df4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/12pg.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/13oracle.t b/t/basicrels/13oracle.t
deleted file mode 100644 (file)
index 54521ea..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/13oracle.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/145db2.t b/t/basicrels/145db2.t
deleted file mode 100644 (file)
index 9573802..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/145db2.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/146db2_400.t b/t/basicrels/146db2_400.t
deleted file mode 100644 (file)
index 2ac494c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/146db2_400.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/14mssql.t b/t/basicrels/14mssql.t
deleted file mode 100644 (file)
index 1417499..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/14mssql.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/15limit.t b/t/basicrels/15limit.t
deleted file mode 100644 (file)
index 496d1b4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/15limit.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/16joins.t b/t/basicrels/16joins.t
deleted file mode 100644 (file)
index 436b0d0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/16joins.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/17join_count.t b/t/basicrels/17join_count.t
deleted file mode 100644 (file)
index 8d20fde..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/17join_count.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/18self_referencial.t b/t/basicrels/18self_referencial.t
deleted file mode 100644 (file)
index 798d6a2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/18self_referencial.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/19uuid.t b/t/basicrels/19uuid.t
deleted file mode 100644 (file)
index ec8222a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/19uuid.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/20unique.t b/t/basicrels/20unique.t
deleted file mode 100644 (file)
index 5a87ef1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/20unique.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/21transactions.t b/t/basicrels/21transactions.t
deleted file mode 100644 (file)
index cea95cf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/21transactions.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/22cascade_copy.t b/t/basicrels/22cascade_copy.t
deleted file mode 100644 (file)
index c670152..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/22cascade_copy.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/23cache.t b/t/basicrels/23cache.t
deleted file mode 100644 (file)
index ca2efee..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/23cache.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/24serialize.t b/t/basicrels/24serialize.t
deleted file mode 100644 (file)
index 1a11191..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/24serialize.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/25utf8.t b/t/basicrels/25utf8.t
deleted file mode 100644 (file)
index c5fe364..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/25utf8.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/26might_have.t b/t/basicrels/26might_have.t
deleted file mode 100644 (file)
index f2942e4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/26might_have.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/28result_set_column.t b/t/basicrels/28result_set_column.t
deleted file mode 100644 (file)
index cff21d7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/28result_set_column.tl";
-run_tests(DBICTest->schema);
diff --git a/t/basicrels/30ensure_class_loaded.t b/t/basicrels/30ensure_class_loaded.t
deleted file mode 100644 (file)
index 67f2d6c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::BasicRels;
-
-require "t/run/30ensure_class_loaded.tl";
-run_tests(DBICTest->schema);
index 9650315..71ccaed 100644 (file)
@@ -15,7 +15,8 @@ BEGIN {
 
 use lib 't/lib';
 
-use_ok('DBICTest::HelperRels');
+use_ok('DBICTest');
+DBICTest->init_schema();
 
 DBICTest::CD->load_components(qw/CDBICompat::Pager/);
 
index 7d3f0bf..658c500 100644 (file)
@@ -43,8 +43,16 @@ use base 'DBIx::Class::Test::SQLite';
 
 City->table('City');
 City->columns(All => qw/Name State Population/);
-City->has_a(State => 'State');
 
+{
+  # Disable the `no such table' warning
+  local $SIG{__WARN__} = sub {
+    my $warning = shift;
+    warn $warning unless ($warning =~ /\Qno such table: City(1)\E/);
+  };
+
+  City->has_a(State => 'State');
+}
 
 #-------------------------------------------------------------------------
 package CD;
index d2fe462..ca7786e 100644 (file)
@@ -38,7 +38,7 @@ ok(
        ok $pj = $btaste->Director, "Bad taste now hasa() director";
        isa_ok $pj => 'Director';
        {
-               no warnings 'redefine';
+               no warnings qw(redefine once);
                local *Ima::DBI::st::execute =
                        sub { ::fail("Shouldn't need to query db"); };
                is $pj->id, 'Peter Jackson', 'ID already stored';
diff --git a/t/helperrels/01core.t b/t/helperrels/01core.t
deleted file mode 100644 (file)
index 1829aef..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/01core.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/04db.t b/t/helperrels/04db.t
deleted file mode 100644 (file)
index 5051ac3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/04db.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/05multipk.t b/t/helperrels/05multipk.t
deleted file mode 100644 (file)
index fc5b046..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/05multipk.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/06relationship.t b/t/helperrels/06relationship.t
deleted file mode 100644 (file)
index c56d936..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/06relationship.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/07pager.t b/t/helperrels/07pager.t
deleted file mode 100644 (file)
index a0b192f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/07pager.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/08inflate.t b/t/helperrels/08inflate.t
deleted file mode 100644 (file)
index 9f1afb5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/08inflate.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/08inflate_has_a.t b/t/helperrels/08inflate_has_a.t
deleted file mode 100644 (file)
index 32641eb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/08inflate_has_a.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/08inflate_serialize.t b/t/helperrels/08inflate_serialize.t
deleted file mode 100644 (file)
index e0ca1d8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/08inflate_serialize.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/09update.t b/t/helperrels/09update.t
deleted file mode 100644 (file)
index 05cc63e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/09update.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/10auto.t b/t/helperrels/10auto.t
deleted file mode 100644 (file)
index 94c0c7c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/10auto.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/11mysql.t b/t/helperrels/11mysql.t
deleted file mode 100644 (file)
index 397f961..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/11mysql.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/12pg.t b/t/helperrels/12pg.t
deleted file mode 100644 (file)
index 281289d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/12pg.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/13oracle.t b/t/helperrels/13oracle.t
deleted file mode 100644 (file)
index 25a6e51..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/13oracle.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/145db2.t b/t/helperrels/145db2.t
deleted file mode 100644 (file)
index c6925ef..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/145db2.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/146db2_400.t b/t/helperrels/146db2_400.t
deleted file mode 100644 (file)
index 655bc05..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/146db2_400.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/14mssql.t b/t/helperrels/14mssql.t
deleted file mode 100644 (file)
index b43847f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/14mssql.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/15limit.t b/t/helperrels/15limit.t
deleted file mode 100644 (file)
index fa22b73..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/15limit.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/16joins.t b/t/helperrels/16joins.t
deleted file mode 100644 (file)
index bf451e9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/16joins.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/17join_count.t b/t/helperrels/17join_count.t
deleted file mode 100644 (file)
index 531d9ff..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/17join_count.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/18self_referencial.t b/t/helperrels/18self_referencial.t
deleted file mode 100644 (file)
index 6cec715..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/18self_referencial.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/19uuid.t b/t/helperrels/19uuid.t
deleted file mode 100644 (file)
index 2d0d4cb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/19uuid.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/20unique.t b/t/helperrels/20unique.t
deleted file mode 100644 (file)
index 91eed2c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/20unique.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/21transactions.t b/t/helperrels/21transactions.t
deleted file mode 100644 (file)
index 5730483..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/21transactions.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/22cascade_copy.t b/t/helperrels/22cascade_copy.t
deleted file mode 100644 (file)
index bc124e1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/22cascade_copy.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/23cache.t b/t/helperrels/23cache.t
deleted file mode 100644 (file)
index 73bc31a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/23cache.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/24serialize.t b/t/helperrels/24serialize.t
deleted file mode 100644 (file)
index bc51393..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/24serialize.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/25utf8.t b/t/helperrels/25utf8.t
deleted file mode 100644 (file)
index ad3fe14..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/25utf8.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/26might_have.t b/t/helperrels/26might_have.t
deleted file mode 100644 (file)
index d3ec615..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/26might_have.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/27ordered.t b/t/helperrels/27ordered.t
deleted file mode 100644 (file)
index 352a730..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/27ordered.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/28result_set_column.t b/t/helperrels/28result_set_column.t
deleted file mode 100644 (file)
index 105b5c7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/28result_set_column.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/29dbicadmin.t b/t/helperrels/29dbicadmin.t
deleted file mode 100644 (file)
index ea5882e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/29dbicadmin.tl";
-run_tests(DBICTest->schema);
diff --git a/t/helperrels/30ensure_class_loaded.t b/t/helperrels/30ensure_class_loaded.t
deleted file mode 100644 (file)
index 6edbe80..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use DBICTest::HelperRels;
-
-require "t/run/30ensure_class_loaded.tl";
-run_tests(DBICTest->schema);
index 5ffdf90..9dbbf55 100755 (executable)
@@ -5,21 +5,233 @@ use strict;
 use warnings;
 use DBICTest::Schema;
 
-sub initialise {
+=head1 NAME
 
-  my $db_file = "t/var/DBIxClass.db";
-  
-  unlink($db_file) if -e $db_file;
-  unlink($db_file . "-journal") if -e $db_file . "-journal";
-  mkdir("t/var") unless -d "t/var";
-  
-  my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}";
-  my $dbuser = $ENV{"DBICTEST_DBUSER"} || '';
-  my $dbpass = $ENV{"DBICTEST_DBPASS"} || '';
+DBICTest - Library to be used by DBIx::Class test scripts.
 
-#  my $dsn = "dbi:SQLite:${db_file}";
+=head1 SYNOPSIS
+
+  use lib qw(t/lib);
+  use DBICTest;
+  use Test::More;
   
-  return DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass);
+  my $schema = DBICTest->init_schema();
+
+=head1 DESCRIPTION
+
+This module provides the basic utilities to write tests against 
+DBIx::Class.
+
+=head1 METHODS
+
+=head2 init_schema
+
+  my $schema = DBICTest->init_schema(
+    no_deploy=>1,
+    no_populate=>1,
+  );
+
+This method removes the test SQLite database in t/var/DBIxClass.db 
+and then creates a new, empty database.
+
+This method will call deploy_schema() by default, unless the 
+no_deploy flag is set.
+
+Also, by default, this method will call populate_schema() by 
+default, unless the no_deploy or no_populate flags are set.
+
+=cut
+
+sub init_schema {
+    my $self = shift;
+    my %args = @_;
+    my $db_file = "t/var/DBIxClass.db";
+
+    unlink($db_file) if -e $db_file;
+    unlink($db_file . "-journal") if -e $db_file . "-journal";
+    mkdir("t/var") unless -d "t/var";
+
+    my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}";
+    my $dbuser = $ENV{"DBICTEST_DBUSER"} || '';
+    my $dbpass = $ENV{"DBICTEST_DBPASS"} || '';
+
+    my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass);
+    if ( !$args{no_deploy} ) {
+        __PACKAGE__->deploy_schema( $schema );
+        __PACKAGE__->populate_schema( $schema ) if( !$args{no_populate} );
+    }
+    return $schema;
 }
-  
+
+=head2 deploy_schema
+
+  DBICTest->deploy_schema( $schema );
+
+This method does one of two things to the schema.  It can either call 
+the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment 
+variable is set, otherwise the default is to read in the t/lib/sqlite.sql 
+file and execute the SQL within. Either way you end up with a fresh set 
+of tables for testing.
+
+=cut
+
+sub deploy_schema {
+    my $self = shift;
+    my $schema = shift;
+
+    if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
+        return $schema->deploy();
+    } else {
+        open IN, "t/lib/sqlite.sql";
+        my $sql;
+        { local $/ = undef; $sql = <IN>; }
+        close IN;
+        $schema->storage->dbh->do($_) for split(/;\n/, $sql);
+    }
+}
+
+=head2 populate_schema
+
+  DBICTest->populate_schema( $schema );
+
+After you deploy your schema you can use this method to populate 
+the tables with test data.
+
+=cut
+
+sub populate_schema {
+    my $self = shift;
+    my $schema = shift;
+
+    $schema->storage->dbh->do("PRAGMA synchronous = OFF");
+
+    $schema->populate('Artist', [
+        [ qw/artistid name/ ],
+        [ 1, 'Caterwauler McCrae' ],
+        [ 2, 'Random Boy Band' ],
+        [ 3, 'We Are Goth' ],
+    ]);
+
+    $schema->populate('CD', [
+        [ qw/cdid artist title year/ ],
+        [ 1, 1, "Spoonful of bees", 1999 ],
+        [ 2, 1, "Forkful of bees", 2001 ],
+        [ 3, 1, "Caterwaulin' Blues", 1997 ],
+        [ 4, 2, "Generic Manufactured Singles", 2001 ],
+        [ 5, 3, "Come Be Depressed With Us", 1998 ],
+    ]);
+
+    $schema->populate('LinerNotes', [
+        [ qw/liner_id notes/ ],
+        [ 2, "Buy Whiskey!" ],
+        [ 4, "Buy Merch!" ],
+        [ 5, "Kill Yourself!" ],
+    ]);
+
+    $schema->populate('Tag', [
+        [ qw/tagid cd tag/ ],
+        [ 1, 1, "Blue" ],
+        [ 2, 2, "Blue" ],
+        [ 3, 3, "Blue" ],
+        [ 4, 5, "Blue" ],
+        [ 5, 2, "Cheesy" ],
+        [ 6, 4, "Cheesy" ],
+        [ 7, 5, "Cheesy" ],
+        [ 8, 2, "Shiny" ],
+        [ 9, 4, "Shiny" ],
+    ]);
+
+    $schema->populate('TwoKeys', [
+        [ qw/artist cd/ ],
+        [ 1, 1 ],
+        [ 1, 2 ],
+        [ 2, 2 ],
+    ]);
+
+    $schema->populate('FourKeys', [
+        [ qw/foo bar hello goodbye/ ],
+        [ 1, 2, 3, 4 ],
+        [ 5, 4, 3, 6 ],
+    ]);
+
+    $schema->populate('OneKey', [
+        [ qw/id artist cd/ ],
+        [ 1, 1, 1 ],
+        [ 2, 1, 2 ],
+        [ 3, 2, 2 ],
+    ]);
+
+    $schema->populate('SelfRef', [
+        [ qw/id name/ ],
+        [ 1, 'First' ],
+        [ 2, 'Second' ],
+    ]);
+
+    $schema->populate('SelfRefAlias', [
+        [ qw/self_ref alias/ ],
+        [ 1, 2 ]
+    ]);
+
+    $schema->populate('ArtistUndirectedMap', [
+        [ qw/id1 id2/ ],
+        [ 1, 2 ]
+    ]);
+
+    $schema->populate('Producer', [
+        [ qw/producerid name/ ],
+        [ 1, 'Matt S Trout' ],
+        [ 2, 'Bob The Builder' ],
+        [ 3, 'Fred The Phenotype' ],
+    ]);
+
+    $schema->populate('CD_to_Producer', [
+        [ qw/cd producer/ ],
+        [ 1, 1 ],
+        [ 1, 2 ],
+        [ 1, 3 ],
+    ]);
+
+    $schema->populate('TreeLike', [
+        [ qw/id parent name/ ],
+        [ 1, 0, 'foo'  ],
+        [ 2, 1, 'bar'  ],
+        [ 3, 2, 'baz'  ],
+        [ 4, 3, 'quux' ],
+    ]);
+
+    $schema->populate('Track', [
+        [ qw/trackid cd  position title/ ],
+        [ 4, 2, 1, "Stung with Success"],
+        [ 5, 2, 2, "Stripy"],
+        [ 6, 2, 3, "Sticky Honey"],
+        [ 7, 3, 1, "Yowlin"],
+        [ 8, 3, 2, "Howlin"],
+        [ 9, 3, 3, "Fowlin"],
+        [ 10, 4, 1, "Boring Name"],
+        [ 11, 4, 2, "Boring Song"],
+        [ 12, 4, 3, "No More Ideas"],
+        [ 13, 5, 1, "Sad"],
+        [ 14, 5, 2, "Under The Weather"],
+        [ 15, 5, 3, "Suicidal"],
+        [ 16, 1, 1, "The Bees Knees"],
+        [ 17, 1, 2, "Apiary"],
+        [ 18, 1, 3, "Beehind You"],
+    ]);
+
+    $schema->populate('Event', [
+        [ qw/id starts_at/ ],
+        [ 1, '2006-04-25 22:24:33' ],
+    ]);
+
+    $schema->populate('Link', [
+        [ qw/id title/ ],
+        [ 1, 'aaa' ]
+    ]);
+
+    $schema->populate('Bookmark', [
+        [ qw/id link/ ],
+        [ 1, 1 ]
+    ]);
+}
+
 1;
diff --git a/t/lib/DBICTest/BasicRels.pm b/t/lib/DBICTest/BasicRels.pm
deleted file mode 100644 (file)
index 0e905df..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package # hide from PAUSE
-    DBICTest::BasicRels;
-
-use DBICTest::Schema;
-use DBICTest::Schema::BasicRels;
-use DBICTest::Setup;
-
-1;
diff --git a/t/lib/DBICTest/HelperRels.pm b/t/lib/DBICTest/HelperRels.pm
deleted file mode 100644 (file)
index 93456ed..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package # hide from PAUSE 
-    DBICTest::HelperRels;
-
-use DBICTest::Schema;
-use DBICTest::Schema::HelperRels;
-use DBICTest::Setup;
-
-1;
index b7ce3f9..72e1da6 100644 (file)
@@ -11,7 +11,6 @@ __PACKAGE__->load_classes(qw/
   CD
   Link
   Bookmark
-  #Casecheck
   #dummy
   Track
   Tag
@@ -32,7 +31,7 @@ __PACKAGE__->load_classes(qw/
     'Producer',
     'CD_to_Producer',
   ),
-  qw/SelfRefAlias TreeLike TwoKeyTreeLike/
+  qw/SelfRefAlias TreeLike TwoKeyTreeLike Event/
 );
 
 1;
index f4c6706..0bb49c4 100644 (file)
@@ -3,10 +3,8 @@ package # hide from PAUSE
 
 use base 'DBIx::Class::Core';
 
-__PACKAGE__->load_components('PK::Auto');
-
-DBICTest::Schema::Artist->table('artist');
-DBICTest::Schema::Artist->add_columns(
+__PACKAGE__->table('artist');
+__PACKAGE__->add_columns(
   'artistid' => {
     data_type => 'integer',
     is_auto_increment => 1
@@ -17,11 +15,25 @@ DBICTest::Schema::Artist->add_columns(
     is_nullable => 1,
   },
 );
-DBICTest::Schema::Artist->set_primary_key('artistid');
+__PACKAGE__->set_primary_key('artistid');
 
 __PACKAGE__->mk_classdata('field_name_for', {
     artistid    => 'primary key',
     name        => 'artist name',
 });
 
+__PACKAGE__->has_many(
+    cds => 'DBICTest::Schema::CD', undef,
+    { order_by => 'year' },
+);
+
+__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' );
+__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' );
+
+__PACKAGE__->has_many(
+  artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
+  [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
+  { cascade_copy => 0 } # this would *so* not make sense
+);
+
 1;
index 6e888ed..2669575 100644 (file)
@@ -10,4 +10,11 @@ __PACKAGE__->add_columns(
 );
 __PACKAGE__->set_primary_key(qw/id1 id2/);
 
+__PACKAGE__->belongs_to( 'artist1', 'DBICTest::Schema::Artist', 'id1' );
+__PACKAGE__->belongs_to( 'artist2', 'DBICTest::Schema::Artist', 'id2');
+__PACKAGE__->has_many(
+  'mapped_artists', 'DBICTest::Schema::Artist',
+  [ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ],
+);
+
 1;
diff --git a/t/lib/DBICTest/Schema/BasicRels.pm b/t/lib/DBICTest/Schema/BasicRels.pm
deleted file mode 100644 (file)
index 161e814..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-package # hide from PAUSE 
-    DBICTest::Schema::BasicRels;
-
-use base 'DBIx::Class::Core';
-
-DBICTest::Schema::Artist->add_relationship(
-    cds => 'DBICTest::Schema::CD',
-    { 'foreign.artist' => 'self.artistid' },
-    { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' }
-);
-DBICTest::Schema::Artist->add_relationship(
-    twokeys => 'DBICTest::Schema::TwoKeys',
-    { 'foreign.artist' => 'self.artistid' },
-    { cascade_copy => 1 }
-);
-DBICTest::Schema::Artist->add_relationship(
-    onekeys => 'DBICTest::Schema::OneKey',
-    { 'foreign.artist' => 'self.artistid' }
-);
-DBICTest::Schema::Artist->add_relationship(
-    artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
-    [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
-    { accessor => 'multi' }
-);
-DBICTest::Schema::ArtistUndirectedMap->add_relationship(
-    'mapped_artists', 'DBICTest::Schema::Artist',
-    [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]
-);
-DBICTest::Schema::CD->add_relationship(
-    artist => 'DBICTest::Schema::Artist',
-    { 'foreign.artistid' => 'self.artist' },
-    { accessor => 'filter' },
-);
-DBICTest::Schema::CD->add_relationship(
-    tracks => 'DBICTest::Schema::Track',
-    { 'foreign.cd' => 'self.cdid' },
-    { join_type => 'LEFT', cascade_delete => 1 }
-);
-DBICTest::Schema::CD->add_relationship(
-    tags => 'DBICTest::Schema::Tag',
-    { 'foreign.cd' => 'self.cdid' },
-    { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi', order_by => 'tag' }
-);
-#DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/);
-DBICTest::Schema::CD->add_relationship(
-    liner_notes => 'DBICTest::Schema::LinerNotes',
-    { 'foreign.liner_id' => 'self.cdid' },
-    { join_type => 'LEFT', accessor => 'single' }
-);
-DBICTest::Schema::CD->add_relationship(
-    cd_to_producer => 'DBICTest::Schema::CD_to_Producer',
-    { 'foreign.cd' => 'self.cdid' },
-    { join_type => 'LEFT', cascade_delete => 1 }
-);
-
-DBICTest::Schema::SelfRefAlias->add_relationship(
-    self_ref => 'DBICTest::Schema::SelfRef',
-    { 'foreign.id' => 'self.self_ref' },
-    { accessor     => 'single' }
-
-);
-DBICTest::Schema::SelfRefAlias->add_relationship(
-    alias => 'DBICTest::Schema::SelfRef',
-    { 'foreign.id' => 'self.alias' },
-    { accessor     => 'single' }
-);
-
-DBICTest::Schema::SelfRef->add_relationship(
-    aliases => 'DBICTest::Schema::SelfRefAlias',
-    { 'foreign.self_ref' => 'self.id' },
-    { accessor => 'multi' }
-);
-
-DBICTest::Schema::Tag->add_relationship(
-    cd => 'DBICTest::Schema::CD',
-    { 'foreign.cdid' => 'self.cd' },
-    { accessor => 'single' }
-);
-
-DBICTest::Schema::Track->add_relationship(
-    cd => 'DBICTest::Schema::CD',
-    { 'foreign.cdid' => 'self.cd' }
-);
-
-DBICTest::Schema::TwoKeys->add_relationship(
-    artist => 'DBICTest::Schema::Artist',
-    { 'foreign.artistid' => 'self.artist' }
-);
-DBICTest::Schema::TwoKeys->add_relationship(
-    cd => 'DBICTest::Schema::CD',
-    { 'foreign.cdid' => 'self.cd' }
-);
-
-DBICTest::Schema::CD_to_Producer->add_relationship(
-    cd => 'DBICTest::Schema::CD',
-    { 'foreign.cdid' => 'self.cd' }
-);
-DBICTest::Schema::CD_to_Producer->add_relationship(
-    producer => 'DBICTest::Schema::Producer',
-    { 'foreign.producerid' => 'self.producer' }
-);
-
-# now the Helpers
-DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
-DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });
-
-1;
index 4f9ec44..72db586 100644 (file)
@@ -7,7 +7,6 @@ package # hide from PAUSE
 use strict;
 use warnings;
 
-__PACKAGE__->load_components(qw/PK::Auto Core/);
 __PACKAGE__->table('bookmark');
 __PACKAGE__->add_columns(qw/id link/);
 __PACKAGE__->add_columns(
index 90e4c0c..7ba727c 100644 (file)
@@ -3,10 +3,8 @@ package # hide from PAUSE
 
 use base 'DBIx::Class::Core';
 
-__PACKAGE__->load_components('PK::Auto');
-
-DBICTest::Schema::CD->table('cd');
-DBICTest::Schema::CD->add_columns(
+__PACKAGE__->table('cd');
+__PACKAGE__->add_columns(
   'cdid' => {
     data_type => 'integer',
     is_auto_increment => 1,
@@ -23,7 +21,28 @@ DBICTest::Schema::CD->add_columns(
     size      => 100,
   },
 );
-DBICTest::Schema::CD->set_primary_key('cdid');
-DBICTest::Schema::CD->add_unique_constraint(artist_title => [ qw/artist title/ ]);
+__PACKAGE__->set_primary_key('cdid');
+__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
+
+__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' );
+
+__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
+__PACKAGE__->has_many(
+    tags => 'DBICTest::Schema::Tag', undef,
+    { order_by => 'tag' },
+);
+__PACKAGE__->has_many(
+    cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
+);
+
+__PACKAGE__->might_have(
+    liner_notes => 'DBICTest::Schema::LinerNotes', undef,
+    { proxy => [ qw/notes/ ] },
+);
+__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
+__PACKAGE__->many_to_many(
+    producers_sorted => cd_to_producer => 'producer',
+    { order_by => 'producer.name' },
+);
 
 1;
index 378c58c..117a590 100644 (file)
@@ -10,4 +10,14 @@ __PACKAGE__->add_columns(
 );
 __PACKAGE__->set_primary_key(qw/cd producer/);
 
+__PACKAGE__->belongs_to(
+  'cd', 'DBICTest::Schema::CD',
+  { 'foreign.cdid' => 'self.cd' }
+);
+
+__PACKAGE__->belongs_to(
+  'producer', 'DBICTest::Schema::Producer',
+  { 'foreign.producerid' => 'self.producer' }
+);
+
 1;
index e91f872..78b3d16 100644 (file)
@@ -1,9 +1,9 @@
 package # hide from PAUSE 
     DBICTest::Schema::Employee;
 
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
 
-__PACKAGE__->load_components(qw( Ordered PK::Auto Core ));
+__PACKAGE__->load_components(qw( Ordered ));
 
 __PACKAGE__->table('employee');
 
diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm
new file mode 100644 (file)
index 0000000..937d782
--- /dev/null
@@ -0,0 +1,18 @@
+package DBICTest::Schema::Event;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('event');
+
+__PACKAGE__->add_columns(
+  id => { data_type => 'integer', is_auto_increment => 1 },
+  starts_at => { data_type => 'datetime' }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/HelperRels.pm b/t/lib/DBICTest/Schema/HelperRels.pm
deleted file mode 100644 (file)
index 45e0ed8..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package # hide from PAUSE 
-    DBICTest::Schema::HelperRels;
-
-use base 'DBIx::Class::Core';
-
-DBICTest::Schema::Artist->has_many(cds => 'DBICTest::Schema::CD', undef,
-                                     { order_by => 'year' });
-DBICTest::Schema::Artist->has_many(twokeys => 'DBICTest::Schema::TwoKeys');
-DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey');
-
-DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist');
-
-DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track');
-DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag', undef,
-                                 { order_by => 'tag' });
-DBICTest::Schema::CD->has_many(cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd');
-
-DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes',
-                                  undef, { proxy => [ qw/notes/ ] });
-
-DBICTest::Schema::SelfRefAlias->belongs_to(
-  self_ref => 'DBICTest::Schema::SelfRef');
-DBICTest::Schema::SelfRefAlias->belongs_to(
-  alias => 'DBICTest::Schema::SelfRef');
-
-DBICTest::Schema::SelfRef->has_many(
-  aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref');
-
-DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD');
-
-DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD');
-DBICTest::Schema::Track->belongs_to('disc', 'DBICTest::Schema::CD', 'cd');
-
-DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist');
-DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD');
-
-DBICTest::Schema::CD_to_Producer->belongs_to(
-  'cd', 'DBICTest::Schema::CD',
-  { 'foreign.cdid' => 'self.cd' }
-);
-DBICTest::Schema::CD_to_Producer->belongs_to(
-  'producer', 'DBICTest::Schema::Producer',
-  { 'foreign.producerid' => 'self.producer' }
-);
-DBICTest::Schema::Artist->has_many(
-  'artist_undirected_maps', 'DBICTest::Schema::ArtistUndirectedMap',
-  [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
-  { cascade_copy => 0 } # this would *so* not make sense
-);
-DBICTest::Schema::ArtistUndirectedMap->belongs_to(
-  'artist1', 'DBICTest::Schema::Artist', 'id1');
-DBICTest::Schema::ArtistUndirectedMap->belongs_to(
-  'artist2', 'DBICTest::Schema::Artist', 'id2');
-DBICTest::Schema::ArtistUndirectedMap->has_many(
-  'mapped_artists', 'DBICTest::Schema::Artist',
-  [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]);
-
-# now the Helpers
-DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
-DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });
-
-1;
index 72574ea..5343122 100644 (file)
@@ -6,7 +6,6 @@ use base 'DBIx::Class::Core';
 use strict;
 use warnings;
 
-__PACKAGE__->load_components(qw/PK::Auto Core/);
 __PACKAGE__->table('link');
 __PACKAGE__->add_columns(
     'id' => {
index dbe7003..4cc2918 100644 (file)
@@ -3,8 +3,6 @@ package # hide from PAUSE
 
 use base 'DBIx::Class::Core';
 
-__PACKAGE__->load_components('PK::Auto');
-
 DBICTest::Schema::OneKey->table('onekey');
 DBICTest::Schema::OneKey->add_columns(
   'id' => {
index 36b63a1..036f9f2 100644 (file)
@@ -15,5 +15,6 @@ __PACKAGE__->add_columns(
   },
 );
 __PACKAGE__->set_primary_key('producerid');
+__PACKAGE__->add_unique_constraint(prod_name => [ qw/name/ ]);
 
 1;
index 474c1a2..ec715c7 100644 (file)
@@ -16,4 +16,6 @@ __PACKAGE__->add_columns(
 );\r
 __PACKAGE__->set_primary_key('id');\r
 \r
+__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' );\r
+\r
 1;\r
index 9d58a8c..e7ed491 100644 (file)
@@ -14,4 +14,7 @@ __PACKAGE__->add_columns(
 );\r
 __PACKAGE__->set_primary_key(qw/self_ref alias/);\r
 \r
+__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' );\r
+__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' );\r
+\r
 1;\r
index b93b622..b75c2ef 100644 (file)
@@ -3,10 +3,8 @@ package # hide from PAUSE
 
 use base qw/DBIx::Class::Core/;
 
-__PACKAGE__->load_components('PK::Auto');
-
-DBICTest::Schema::Tag->table('tags');
-DBICTest::Schema::Tag->add_columns(
+__PACKAGE__->table('tags');
+__PACKAGE__->add_columns(
   'tagid' => {
     data_type => 'integer',
     is_auto_increment => 1,
@@ -19,6 +17,8 @@ DBICTest::Schema::Tag->add_columns(
     size      => 100,
   },
 );
-DBICTest::Schema::Tag->set_primary_key('tagid');
+__PACKAGE__->set_primary_key('tagid');
+
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
 
 1;
index 9bbefff..691974a 100644 (file)
@@ -3,8 +3,8 @@ package # hide from PAUSE
 
 use base 'DBIx::Class::Core';
 
-DBICTest::Schema::Track->table('track');
-DBICTest::Schema::Track->add_columns(
+__PACKAGE__->table('track');
+__PACKAGE__->add_columns(
   'trackid' => {
     data_type => 'integer',
     is_auto_increment => 1,
@@ -21,6 +21,9 @@ DBICTest::Schema::Track->add_columns(
     size      => 100,
   },
 );
-DBICTest::Schema::Track->set_primary_key('trackid');
+__PACKAGE__->set_primary_key('trackid');
+
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
+__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd');
 
 1;
index 1eca3e1..73f9143 100644 (file)
@@ -1,9 +1,7 @@
 package # hide from PAUSE 
     DBICTest::Schema::TreeLike;
 
-use base qw/DBIx::Class/;
-
-__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
+use base qw/DBIx::Class::Core/;
 
 __PACKAGE__->table('treelike');
 __PACKAGE__->add_columns(
index c7258e0..1c1b7b9 100644 (file)
@@ -1,9 +1,7 @@
 package # hide from PAUSE 
     DBICTest::Schema::TwoKeyTreeLike;
 
-use base qw/DBIx::Class/;
-
-__PACKAGE__->load_components(qw/Core/);
+use base qw/DBIx::Class::Core/;
 
 __PACKAGE__->table('twokeytreelike');
 __PACKAGE__->add_columns(
index 91a6fef..8483d0b 100755 (executable)
@@ -3,11 +3,14 @@ package # hide from PAUSE
 
 use base 'DBIx::Class::Core';
 
-DBICTest::Schema::TwoKeys->table('twokeys');
-DBICTest::Schema::TwoKeys->add_columns(
+__PACKAGE__->table('twokeys');
+__PACKAGE__->add_columns(
   'artist' => { data_type => 'integer' },
   'cd' => { data_type => 'integer' },
 );
-DBICTest::Schema::TwoKeys->set_primary_key(qw/artist cd/);
+__PACKAGE__->set_primary_key(qw/artist cd/);
+
+__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' );
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
 
 1;
diff --git a/t/lib/DBICTest/Setup.pm b/t/lib/DBICTest/Setup.pm
deleted file mode 100755 (executable)
index b493cb6..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-use strict;
-use warnings;
-use DBICTest;
-
-my $schema = DBICTest->initialise;
-
-# $schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]);
-
-my $dbh = $schema->storage->dbh;
-
-if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
-  $schema->deploy;
-} else {
-  open IN, "t/lib/sqlite.sql";
-
-  my $sql;
-
-  { local $/ = undef; $sql = <IN>; }
-
-  close IN;
-
-  $dbh->do($_) for split(/;\n/, $sql);
-}
-
-$schema->storage->dbh->do("PRAGMA synchronous = OFF");
-
-$schema->populate('Artist', [
-  [ qw/artistid name/ ],
-  [ 1, 'Caterwauler McCrae' ],
-  [ 2, 'Random Boy Band' ],
-  [ 3, 'We Are Goth' ],
-]);
-
-$schema->populate('CD', [
-  [ qw/cdid artist title year/ ],
-  [ 1, 1, "Spoonful of bees", 1999 ],
-  [ 2, 1, "Forkful of bees", 2001 ],
-  [ 3, 1, "Caterwaulin' Blues", 1997 ],
-  [ 4, 2, "Generic Manufactured Singles", 2001 ],
-  [ 5, 3, "Come Be Depressed With Us", 1998 ],
-]);
-
-$schema->populate('LinerNotes', [
-  [ qw/liner_id notes/ ],
-  [ 2, "Buy Whiskey!" ],
-  [ 4, "Buy Merch!" ],
-  [ 5, "Kill Yourself!" ],
-]);
-
-$schema->populate('Tag', [
-  [ qw/tagid cd tag/ ],
-  [ 1, 1, "Blue" ],
-  [ 2, 2, "Blue" ],
-  [ 3, 3, "Blue" ],
-  [ 4, 5, "Blue" ],
-  [ 5, 2, "Cheesy" ],
-  [ 6, 4, "Cheesy" ],
-  [ 7, 5, "Cheesy" ],
-  [ 8, 2, "Shiny" ],
-  [ 9, 4, "Shiny" ],
-]);
-
-$schema->populate('TwoKeys', [
-  [ qw/artist cd/ ],
-  [ 1, 1 ],
-  [ 1, 2 ],
-  [ 2, 2 ],
-]);
-
-$schema->populate('FourKeys', [
-  [ qw/foo bar hello goodbye/ ],
-  [ 1, 2, 3, 4 ],
-  [ 5, 4, 3, 6 ],
-]);
-
-$schema->populate('OneKey', [
-  [ qw/id artist cd/ ],
-  [ 1, 1, 1 ],
-  [ 2, 1, 2 ],
-  [ 3, 2, 2 ],
-]);
-
-$schema->populate('SelfRef', [
-  [ qw/id name/ ],
-  [ 1, 'First' ],
-  [ 2, 'Second' ],
-]);
-
-$schema->populate('SelfRefAlias', [
-  [ qw/self_ref alias/ ],
-  [ 1, 2 ]
-]);
-
-$schema->populate('ArtistUndirectedMap', [
-  [ qw/id1 id2/ ],
-  [ 1, 2 ]
-]);
-
-$schema->populate('Producer', [
-  [ qw/producerid name/ ],
-  [ 1, 'Matt S Trout' ],
-  [ 2, 'Bob The Builder' ],
-  [ 3, 'Fred The Phenotype' ],
-]);
-
-$schema->populate('CD_to_Producer', [
-  [ qw/cd producer/ ],
-  [ 1, 1 ],
-  [ 1, 2 ],
-  [ 1, 3 ],
-]);
-
-$schema->populate('TreeLike', [
-  [ qw/id parent name/ ],
-  [ 1, 0, 'foo'  ],
-  [ 2, 1, 'bar'  ],
-  [ 3, 2, 'baz'  ],
-  [ 4, 3, 'quux' ],
-]);
-
-$schema->populate('Track', [
-  [ qw/trackid cd  position title/ ],
-  [ 4, 2, 1, "Stung with Success"],
-  [ 5, 2, 2, "Stripy"],
-  [ 6, 2, 3, "Sticky Honey"],
-  [ 7, 3, 1, "Yowlin"],
-  [ 8, 3, 2, "Howlin"],
-  [ 9, 3, 3, "Fowlin"],
-  [ 10, 4, 1, "Boring Name"],
-  [ 11, 4, 2, "Boring Song"],
-  [ 12, 4, 3, "No More Ideas"],
-  [ 13, 5, 1, "Sad"],
-  [ 14, 5, 2, "Under The Weather"],
-  [ 15, 5, 3, "Suicidal"],
-  [ 16, 1, 1, "The Bees Knees"],
-  [ 17, 1, 2, "Apiary"],
-  [ 18, 1, 3, "Beehind You"],
-]);
-
-$schema->populate('Link', [
-  [ qw/id title/ ],
-  [ 1, 'aaa' ]
-]);
-
-$schema->populate('Bookmark', [
-  [ qw/id link/ ],
-  [ 1, 1 ]
-]);
-
-1;
index 7a13900..d7fa393 100644 (file)
@@ -1,6 +1,6 @@
 -- 
 -- Created by SQL::Translator::Producer::SQLite
--- Created on Sun May 14 18:25:49 2006
+-- Created on Sat May 27 21:28:05 2006
 -- 
 BEGIN TRANSACTION;
 
@@ -132,6 +132,14 @@ CREATE TABLE link (
 );
 
 --
+-- Table: event
+--
+CREATE TABLE event (
+  id INTEGER PRIMARY KEY NOT NULL,
+  starts_at datetime NOT NULL
+);
+
+--
 -- Table: twokeys
 --
 CREATE TABLE twokeys (
@@ -178,5 +186,6 @@ CREATE TABLE producer (
 );
 
 CREATE UNIQUE INDEX tktlnameunique_twokeytreelike on twokeytreelike (name);
-CREATE UNIQUE INDEX artist_title_cd on cd (artist, title);
+CREATE UNIQUE INDEX cd_artist_title_cd on cd (artist, title);
+CREATE UNIQUE INDEX prod_name_producer on producer (name);
 COMMIT;
diff --git a/t/run/25utf8.tl b/t/run/25utf8.tl
deleted file mode 100644 (file)
index 278dde4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-sub run_tests {
-    my $schema = shift;
-
-    eval 'use Encode ; 1'
-        or plan skip_all, 'Install Encode run this test';
-
-    plan tests => 2;
-
-    DBICTest::Schema::Artist->load_components('UTF8Columns');
-    DBICTest::Schema::Artist->utf8_columns('name');
-    Class::C3->reinitialize();
-
-    my $artist = $schema->resultset("Artist")->create( { name => 'uni' } );
-    ok( Encode::is_utf8( $artist->name ), 'got name with utf8 flag' );
-
-    my $utf8_char = 'uniuni';
-    Encode::_utf8_on($utf8_char);
-    $artist->name($utf8_char);
-    ok( !Encode::is_utf8( $artist->{_column_data}->{name} ),
-        'store utf8 less chars' );
-}
-
-1;
diff --git a/t/run/28result_set_column.tl b/t/run/28result_set_column.tl
deleted file mode 100644 (file)
index e62cb62..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-sub run_tests {
-my $schema = shift;
-
-plan tests => 5; 
-
-my $rs = $cd = $schema->resultset("CD")->search({});
-
-my $rs_title = $rs->get_column('title');
-my $rs_year = $rs->get_column('year');
-
-is($rs_title->next, 'Spoonful of bees', "next okay");
-
-my @all = $rs_title->all;
-cmp_ok(scalar @all, '==', 5, "five titles returned");
-
-cmp_ok($rs_year->max, '==', 2001, "max okay for year");
-is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title");
-
-cmp_ok($rs_year->sum, '==', 9996, "three artists returned");
-
-}
-
-1;
diff --git a/t/run/29dbicadmin.tl b/t/run/29dbicadmin.tl
deleted file mode 100644 (file)
index 93c42a1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# vim: filetype=perl
-
-sub run_tests {
-
-    eval 'require JSON';
-    plan skip_all, 'Install JSON to run this test' if ($@);
-
-    eval 'require Text::CSV_XS';
-    if ($@) {
-        eval 'require Text::CSV_PP';
-        plan skip_all, 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@);
-    }
-
-    plan tests => 5;
-    my $schema = shift;
-
-    my $employees = $schema->resultset('Employee');
-    my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|;
-
-    `$cmd --op=insert --set='{name:"Matt"}'`;
-    ok( ($employees->count()==1), 'insert count' );
-
-    my $employee = $employees->find(1);
-    ok( ($employee->name() eq 'Matt'), 'insert valid' );
-
-    `$cmd --op=update --set='{name:"Trout"}'`;
-    $employee = $employees->find(1);
-    ok( ($employee->name() eq 'Trout'), 'update' );
-
-    `$cmd --op=insert --set='{name:"Aran"}'`;
-    my $data = `$cmd --op=select --attrs='{order_by:"name"}'`;
-    ok( ($data=~/Aran.*Trout/s), 'select with attrs' );
-
-    `$cmd --op=delete --where='{name:"Trout"}'`;
-    ok( ($employees->count()==1), 'delete' );
-}
-
-1;