[Bast-commits] r7834 - in
branches/DBIx-Class-Schema-Loader/back-compat: .
lib/DBIx/Class/Schema lib/DBIx/Class/Schema/Loader
lib/DBIx/Class/Schema/Loader/DBI
lib/DBIx/Class/Schema/Loader/DBI/ODBC
lib/DBIx/Class/Schema/Loader/DBI/Sybase t t/lib
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sun Nov 1 09:19:27 GMT 2009
Author: caelum
Date: 2009-11-01 09:19:27 +0000 (Sun, 01 Nov 2009)
New Revision: 7834
Added:
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm
branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_common.t
branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm
Modified:
branches/DBIx-Class-Schema-Loader/back-compat/
branches/DBIx-Class-Schema-Loader/back-compat/Changes
branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
branches/DBIx-Class-Schema-Loader/back-compat/t/11mysql_common.t
branches/DBIx-Class-Schema-Loader/back-compat/t/13db2_common.t
branches/DBIx-Class-Schema-Loader/back-compat/t/15sybase_common.t
branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_odbc_common.t
branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm
Log:
r18689 at hlagh (orig r7408): caelum | 2009-08-28 20:55:06 -0400
r6812 at hlagh (orig r6811): caelum | 2009-06-28 00:08:58 -0400
new branch
r6814 at hlagh (orig r6813): caelum | 2009-06-28 02:52:09 -0400
result class is generated for table with dot in name, but doesn't work yet
r6864 at hlagh (orig r6863): caelum | 2009-06-29 20:18:30 -0400
automatically set quote_char and name_sep for mssql
r6865 at hlagh (orig r6864): caelum | 2009-06-29 20:39:46 -0400
quote table names that include name_sep
r6879 at hlagh (orig r6878): caelum | 2009-06-30 09:48:39 -0400
add constraint to dot in table name test
r6880 at hlagh (orig r6879): caelum | 2009-06-30 09:49:44 -0400
rename test
r6881 at hlagh (orig r6880): caelum | 2009-06-30 10:03:30 -0400
add a test for mssql through dbd::sybase (which fails) and make mssql_dot_in_table_name test work for either sybase or odbc
r6902 at hlagh (orig r6901): caelum | 2009-07-01 00:03:12 -0400
determine db_schema for mssql if not supplied
r6911 at hlagh (orig r6910): caelum | 2009-07-01 07:30:38 -0400
minor changes
r6912 at hlagh (orig r6911): caelum | 2009-07-01 09:06:12 -0400
make mssql test get futher with dbd::sybase
r6923 at hlagh (orig r6922): caelum | 2009-07-01 12:35:11 -0400
mssql now passes against DBD::Sybase
r6929 at hlagh (orig r6928): caelum | 2009-07-02 00:39:37 -0400
merging in sybase branch
r6933 at hlagh (orig r6932): caelum | 2009-07-02 02:24:46 -0400
making some progress on Sybase
r6958 at hlagh (orig r6957): caelum | 2009-07-02 21:29:49 -0400
rels are still fucked in sybase
r6960 at hlagh (orig r6959): caelum | 2009-07-02 23:33:07 -0400
fix pg
r6961 at hlagh (orig r6960): caelum | 2009-07-03 00:34:33 -0400
sybase rels sort of work now, more than half-way through common tests
r6979 at hlagh (orig r6978): caelum | 2009-07-03 15:35:38 -0400
almost passes sybase tests now
r7002 at hlagh (orig r7001): caelum | 2009-07-07 07:58:19 -0400
add comment about sybase DSN
r7026 at hlagh (orig r7025): caelum | 2009-07-10 16:53:09 -0400
make tests pass
r7364 at hlagh (orig r7363): caelum | 2009-08-23 03:37:54 -0400
put extra mssql tests in the proper format
r7378 at hlagh (orig r7377): caelum | 2009-08-24 11:39:56 -0400
finished cleaning up branch, all tests pass
r18687 at hlagh (orig r7406): caelum | 2009-08-28 20:45:12 -0400
add sybase and mssql as features to Makefile.PL
r18688 at hlagh (orig r7407): caelum | 2009-08-28 20:53:37 -0400
remove comment about sybase dsn (it's handled automatically now)
r18691 at hlagh (orig r7410): caelum | 2009-08-28 21:14:40 -0400
add note about sybase dbic branch
r18692 at hlagh (orig r7411): caelum | 2009-08-28 21:21:53 -0400
dev release
r18693 at hlagh (orig r7412): caelum | 2009-08-28 21:23:05 -0400
update M::I version in Makefile.PL
r18694 at hlagh (orig r7413): caelum | 2009-08-28 21:26:05 -0400
fix warning in MySQL tests
r20606 at hlagh (orig r7618): caelum | 2009-09-10 02:06:45 -0400
remove dbic option from sybase test that is no longer necessary
r20845 at hlagh (orig r7763): ash | 2009-10-05 09:17:40 -0400
Only redump the files when something has actually changed
r20846 at hlagh (orig r7764): ash | 2009-10-05 09:38:45 -0400
Place a warning at the top of the files too
r20849 at hlagh (orig r7767): caelum | 2009-10-07 21:56:53 -0400
new dev release
r20944 at hlagh (orig r7782): caelum | 2009-10-13 10:46:22 -0400
patch from Robert Bohne to make _table_uniq_info more correct for Oracle
r21079 at hlagh (orig r7825): caelum | 2009-10-31 07:19:24 -0400
fix data_type for identities in MSSQL RT#50523
r21080 at hlagh (orig r7826): caelum | 2009-10-31 08:32:31 -0400
new dev release
r21081 at hlagh (orig r7827): caelum | 2009-10-31 08:52:58 -0400
add resources to Makefile.PL
r21083 at hlagh (orig r7829): caelum | 2009-10-31 09:12:36 -0400
fix up alignment in Changes
r21087 at hlagh (orig r7833): caelum | 2009-11-01 01:51:33 -0400
run advanced tests on SQLite too
Property changes on: branches/DBIx-Class-Schema-Loader/back-compat
___________________________________________________________________
Name: svk:merge
- 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
+ 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/current:7833
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
Modified: branches/DBIx-Class-Schema-Loader/back-compat/Changes
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/Changes 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/Changes 2009-11-01 09:19:27 UTC (rev 7834)
@@ -1,18 +1,30 @@
Revision history for Perl extension DBIx::Class::Schema::Loader
-0.04999_08 Not Yet Released
+0.04999_10 2009-10-31 12:28:53
+ - patch from Robert Bohne to make _table_uniq_info more correct for
+ Oracle
+ - fix data_type for identity columns with MSSQL
+
+0.04999_09 2009-10-08
+ - Only redump the files when something has actually changed
+ - Place a warning at the top of the files saying 'do not modify' to
+ match the one at the bottom of the auto-gen'd section
+
+0.04999_08 2009-08-28
- Replace UNIVERSAL::require with Class::C3::Componentised
- Add Sybase/MSSQL support through DBD::Sybase
- - use $dbh->get_info(29/41) for qote_car/name_sep if available(semifor)
+ - use $dbh->get_info(29/41) for qote_car/name_sep if available (semifor)
- add MSSQL support through DBD::ODBC
+ - support MSSQL table names with a '.' in the name
+ - support MySQL CURRENT_TIMESTAMP()
-0.04999_07 2009-04-18
+0.04999_07 2009-04-18
- Add result_base_class and schema_base_class options (RT #43977)
- Ignore duplicate uniq indices (including duplicates of the PK).
- Fix for DBD::SQLite 1.20
- Fix for DBIx::Class 0.08100
-0.04999_06 Tue Nov 11, 2008
+0.04999_06 Tue Nov 11, 2008
- Singularise table monikers by default
- Strip trailing _id from single-column belongs_to relationships
- Add "dbicdump" script for easy commandline dumping
@@ -20,9 +32,9 @@
directory if the user didn't specify one
- Fix Oracle constraint and auto-increment detection for non-owned schemas
(RT #35732)
- - Handle ResultSetManager deprecation warning in common tests
+ - Handle ResultSetManager deprecation warning in common tests
-0.04999_05 Mon Apr 14, 2008
+0.04999_05 Mon Apr 14, 2008
- Fix limiting table list to the specified schema for DB2
- Default db_schema to the username for DB2
- Allow specifying a custom loader_class, overriding the
@@ -34,18 +46,18 @@
- Run the common tests against both dynamic and dumped versions of
the schema
-0.04999_04 Wed Mar 12, 2008
+0.04999_04 Wed Mar 12, 2008
- Add is_auto_increment detecton for DB2
-0.04999_03 Wed Mar 12, 2008
+0.04999_03 Wed Mar 12, 2008
- Fix DB2 support
-0.04999_02 Tue Feb 12, 2008
+0.04999_02 Tue Feb 12, 2008
- Add is_auto_increment detection for Oracle
- Unnhide the Oracle module now that the CPAN perms are sorted
out. Thanks to Tsunoda Kazuya for the quick response.
-0.04999_01 Tue Feb 5, 2008
+0.04999_01 Tue Feb 5, 2008
- Mark foreign key columns with is_foreign_key => 1
- Add support for vendor-specific extra column attributes.
- Add support for extra => { unsigned => 1 } for MySQL.
@@ -63,12 +75,12 @@
- Default Oracle db_schema to db username (patch
from Johannes Plunien)
-0.04003 Wed Oct 4, 2007
+0.04003 Wed Oct 4, 2007
- Prevent users from running Kwalitee test automatically
- Fix extra whitespace being added to output on
regeneration (from ilmari)
-0.04002 Tue Jul 24, 2007
+0.04002 Tue Jul 24, 2007
- rescan method now returns the actual list of new tables
loaded (previously, the return value wasn't taking
constraint/exclude into account, even though the meat
@@ -79,27 +91,27 @@
- Fix Win32 test skip counts (RT #27715, Alexandr Ciornii)
- Fix a small output quoting bug (RT #28073, Tokuhiro Matsuno)
-0.04001 Tue Jun 26, 2007
+0.04001 Tue Jun 26, 2007
- Deprecated dump_overwrite. The changed behavior from
0.03xxx was confusing.
- Added new option really_erase_my_files, which does what
dump_overwrite did in 0.04000, which is not what it did
in 0.03xxx.
-0.04000 Thu Jun 7, 2007
+0.04000 Thu Jun 7, 2007
- Added some env vars for controlling the Makefile.PL feature
questions, to make automation easier.
-0.03999_02 Tue May 22, 2007
+0.03999_02 Tue May 22, 2007
- Converted to Module::Install
-0.03012 Tue May 22, 2007
+0.03012 Tue May 22, 2007
- Relationship names for multiple multi-col rels between
the same table fixed by ilmari
- Fix from Marc Espie for CREATE TABLE 'foo' for SQLite
- skip ^sqlite_ tables in SQLite (thanks chromatic)
-0.03999_01 Sat Apr 14 19:57:40 GMT 2007
+0.03999_01 Sat Apr 14 19:57:40 GMT 2007
- Added *experimental* Oracle support from work done
by Tsunoda Kazuya some months ago. Not well tested.
- Added "rescan" schema (and loader) method, which picks
@@ -115,35 +127,35 @@
- Removed previously deprecated methods/options
- Added $VERSION to all packages in this dist
-0.03011 Sat Apr 14 19:03:07 UTC 2007
+0.03011 Sat Apr 14 19:03:07 UTC 2007
- fix case-sensitivity in UNIQUE parsing for SQLite
-0.03010 Thu Mar 29 12:36:19 UTC 2007
+0.03010 Thu Mar 29 12:36:19 UTC 2007
- Workaround for new incompatible changes in DBD::mysql's "tables"
method, which was causing us to find no tables w/ DBD::mysql
4.002+
- Fixed quoting problem in _table_columns (could cause crash when
dumping/doing a static create) (from ash)
-0.03009 Wed Nov 15 14:03:37 UTC 2006
+0.03009 Wed Nov 15 14:03:37 UTC 2006
- fix for rt.cpan.org #22425 (use File::Spec where appropriate)
- use full instead of short classnames in relationships (from victori)
-0.03008 Fri Oct 20 18:08:20 UTC 2006
+0.03008 Fri Oct 20 18:08:20 UTC 2006
- fix for rt.cpan.org #21084 (dump_overwrite pathological output recursion)
- fix for rt.cpan.org #21758 (mysql reserved words as table names)
- fix for rt.cpan.org #21025 (SQLite FK parsing)
- workaround for rt.cpan.org #21746 ($Class::Accessor::Fast::VERSION issues)
-0.03007 Thu Jul 27 16:19:59 UTC 2006
+0.03007 Thu Jul 27 16:19:59 UTC 2006
- Kill erroneous warning about connect/loader_options order (the real
case is warned about elsewhere)
- Fix t/22dump to work around ActiveState issues
-0.03006 Wed Jul 26 00:14:58 UTC 2006
+0.03006 Wed Jul 26 00:14:58 UTC 2006
- Fixed column-case issue w/ columns_info_for
-0.03005 Wed Jul 19 15:09:30 UTC 2006
+0.03005 Wed Jul 19 15:09:30 UTC 2006
[ Pretty much everything in this release originates from nilsonsfj patches ]
- bugfix: mysql unique constraint code had an
obvious but longstanding error
@@ -153,7 +165,7 @@
- dump code now skips+warns instead of dies when
dump_overwrite not set
-0.03004 Tue Jul 11 04:38:09 UTC 2006
+0.03004 Tue Jul 11 04:38:09 UTC 2006
- make_schema_at efficiency improvements
- improved debugging output
- column metadata now included in dumped schemas
@@ -168,14 +180,14 @@
warnings (most did before).
- Somewhat improved test coverage
-0.03003 Tue Jun 6 02:22:49 UTC 2006
+0.03003 Tue Jun 6 02:22:49 UTC 2006
- Fix inclusion of external add-on class definitions
in dump_to_dir output.
-0.03002 Tue Jun 6 01:27:25 UTC 2006
+0.03002 Tue Jun 6 01:27:25 UTC 2006
- rethrow exceptions that occur during make_schema_at
-0.03001 Mon Jun 5 23:17:57 UTC 2006
+0.03001 Mon Jun 5 23:17:57 UTC 2006
- load_from_connection deprecation notice now mentions
upgrading Catalyst::Model::DBIC::Schema if that module
seems to be in use.
@@ -183,15 +195,15 @@
- Loader statement caching for better load-time performance
- Improved Pg unique index loader, based on RDBO
-0.03000 Tue May 23 12:56:05 UTC 2006
+0.03000 Tue May 23 12:56:05 UTC 2006
- weakened the circular schema reference
-0.02999_10 Mon May 22 18:58:20 UTC 2006
+0.02999_10 Mon May 22 18:58:20 UTC 2006
- a few more small bugfixes
- more dump/debug improvements
- new exportable function "make_schema_at"
-0.02999_09 Sun May 21 23:26:58 UTC 2006
+0.02999_09 Sun May 21 23:26:58 UTC 2006
- More docs improvements
- default uniq_info just warns and returns nothing now,
instead of dying. In theory, this allows unsupported
@@ -201,7 +213,7 @@
methods of connecting a Schema::Loader class/object.
- Bugfix to the new runtime object connect/load code.
-0.02999_08 Sat May 20 22:36:45 UTC 2006
+0.02999_08 Sat May 20 22:36:45 UTC 2006
- support for dumping to a directory for
conversion to manual DBIx::Class::Schema
- improved debugging output
@@ -211,7 +223,7 @@
- A couple of bugfixes related to db vendor "schemas", including
a fix for http://rt.cpan.org/Public/Bug/Display.html?id=19164
-0.02999_06 Thu May 18 16:32:41 UTC 2006
+0.02999_06 Thu May 18 16:32:41 UTC 2006
- backwards compat with all earlier versions
- no longer requires schema class to have a connection
- correctly determine source class names in the rel code generator
@@ -220,7 +232,7 @@
- docs updated
- various trivial updates / fixes
-0.02999_05 Sun Mar 26 06:46:09 UTC 2006
+0.02999_05 Sun Mar 26 06:46:09 UTC 2006
- bugfixes to constraint/exclude code
- friendly warnings if we don't find any tables
- inflect_map becomes inflect_plural and inflect_singular
@@ -228,21 +240,21 @@
- Test updates
- Supports multiple rels between the same pair of tables
-0.02007 Wed Mar 22 06:03:53 UTC 2006
+0.02007 Wed Mar 22 06:03:53 UTC 2006
- Backported Class::C3::reinitialize changes from -refactor
branch, resulting in significantly reduced load time
-0.02006 Fri Mar 17 04:55:55 UTC 2006
+0.02006 Fri Mar 17 04:55:55 UTC 2006
- Fix long-standing table/col-name case bugs
-0.02999_04 Fri Mar 17 03:55:09 UTC 2006
+0.02999_04 Fri Mar 17 03:55:09 UTC 2006
- Fixed case-sensitivity issues for table/col names
- Punt columns_info_for to ->storage
- Large loading speedup (get rid of redundant C3 reinits)
- Removed TEST_POD checks
- Removed unneccesary storage->disconnect
-0.02999_03 Mon Mar 13 15:01:11 UTC 2006
+0.02999_03 Mon Mar 13 15:01:11 UTC 2006
- Added EXAMPLE section to pod [Kieren Diment]
- Invasive heavy changes to the DBI- and vendor-specific code
(expect some breakage in some cases until this settles down)
@@ -252,31 +264,31 @@
the changes that are coming, but still does basically what
it did before (this work is the next step).
-0.02999_02 Sat Mar 4 16:53:21 UTC 2006
+0.02999_02 Sat Mar 4 16:53:21 UTC 2006
- Merged in relevant changes from trunk since the split
-0.02005 Mon Feb 27 23:53:17 UTC 2006
+0.02005 Mon Feb 27 23:53:17 UTC 2006
- Move the external file loading to after everything else
loader does, in case people want to define, override, or
build on top of the rels.
-0.02004 Mon Feb 27 23:53:17 UTC 2006
+0.02004 Mon Feb 27 23:53:17 UTC 2006
- Minor fix to debugging message for loading external files
-0.02999_01 Sun Feb 28 00:24:00 UTC 2006
+0.02999_01 Sun Feb 28 00:24:00 UTC 2006
- Shuffle the modules around
- Make ourselves theoretically storage_type-agnostic
- Remove the _db_classes stuff, bump PK::Auto to Base
- Change default inflections to Lingua::EN::Inflect::Number::to_PL()
-0.02003 Sun Feb 19 20:42:01 UTC 2006
+0.02003 Sun Feb 19 20:42:01 UTC 2006
- Deprecated arguments: dsn, user, password, options
- New argument: connect_info
-0.02002 Sat Feb 18 19:53:12 UTC 2006
+0.02002 Sat Feb 18 19:53:12 UTC 2006
- Added moniker_map and inflect_map
-0.02001 Fri Feb 17 20:25:40 UTC 2006
+0.02001 Fri Feb 17 20:25:40 UTC 2006
- tests fixed up a bit
- auto-loading of on-disk class definitions layered on top
of the generated definitions (create Foo::Schema::Bar, then
@@ -287,20 +299,20 @@
is virtually gauranteed to cause subtle mod_perl problems
without those fixes.
-0.02000 Sun Feb 12 22:43:47 UTC 2006
+0.02000 Sun Feb 12 22:43:47 UTC 2006
- Just docs/version update, 0.01004 code released as 0.02000
-0.01004 Tue Feb 7 03:58:01 UTC 2006
+0.01004 Tue Feb 7 03:58:01 UTC 2006
- No longer tries to parse out the table name from the dsn for mysql,
was unneccesary vestigial code from previous method.
-0.01003 Mon Feb 6 14:57:56 UTC 2006
+0.01003 Mon Feb 6 14:57:56 UTC 2006
- Fixed the has_many side of _make_cond_rel
-0.01002 Fri Feb 3 23:14:38 UTC 2006
+0.01002 Fri Feb 3 23:14:38 UTC 2006
- Email address typo :(
-0.01001 Fri Feb 3 05:15:41 UTC 2006
+0.01001 Fri Feb 3 05:15:41 UTC 2006
- Fixed up some documentation issues
- Load C3 at the right time
Modified: branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL 2009-11-01 09:19:27 UTC (rev 7834)
@@ -1,6 +1,5 @@
+use inc::Module::Install 0.91;
-use inc::Module::Install 0.71;
-
name 'DBIx-Class-Schema-Loader';
all_from 'lib/DBIx/Class/Schema/Loader.pm';
@@ -23,7 +22,7 @@
requires 'Class::C3::Componentised' => '1.0005';
requires 'Carp::Clan' => 0;
requires 'Class::Inspector' => 0;
-requires 'DBIx::Class' => '0.07006';
+requires 'DBIx::Class' => '0.08109';
requires 'Class::Unload' => 0;
install_script 'script/dbicdump';
@@ -81,6 +80,30 @@
'DBD::Oracle' => '0.19',
],
},
+ SYBASE => {
+ label => 'Sybase Support (experimental)',
+ def => $ENV{DBIC_FEATURE_SYBASE} || 0,
+ deps => [
+ 'DBI' => '1.56',
+ 'DBD::Sybase' => '1.09',
+ ],
+ },
+ MSSQL => {
+ label => 'Microsoft SQL Server Support via DBD::Sybase (experimental)',
+ def => $ENV{DBIC_FEATURE_MSSQL} || 0,
+ deps => [
+ 'DBI' => '1.56',
+ 'DBD::Sybase' => '1.09',
+ ],
+ },
+ MSSQL_ODBC => {
+ label => 'Microsoft SQL Server Support via DBD::ODBC (experimental)',
+ def => $ENV{DBIC_FEATURE_MSSQL} || 0,
+ deps => [
+ 'DBI' => '1.56',
+ 'DBD::ODBC' => '1.22',
+ ],
+ },
];
for(my $i = 0; $i <= $#$_features - 1; $i += 2) {
@@ -104,6 +127,11 @@
system("pod2text lib/DBIx/Class/Schema/Loader.pm > README");
}
+resources 'IRC' => 'irc://irc.perl.org/#dbix-class';
+resources 'license' => 'http://dev.perl.org/licenses/';
+resources 'repository' => 'http://dev.catalyst.perl.org/repos/bast/branches/DBIx-Class-Schema-Loader/current/';
+resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
+
auto_provides;
auto_install;
WriteAll;
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -16,7 +16,7 @@
use Class::Unload;
require DBIx::Class;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
__PACKAGE__->mk_ro_accessors(qw/
schema
@@ -265,11 +265,19 @@
if $self->{dump_overwrite};
$self->{dynamic} = ! $self->{dump_directory};
- $self->{dump_directory} ||= File::Temp::tempdir( 'dbicXXXX',
+ $self->{temp_directory} ||= File::Temp::tempdir( 'dbicXXXX',
TMPDIR => 1,
CLEANUP => 1,
);
+
+ $self->{dump_directory} ||= $self->{temp_directory};
+
+ $self->{relbuilder} = DBIx::Class::Schema::Loader::RelBuilder->new(
+ $self->schema, $self->inflect_plural, $self->inflect_singular
+ ) if !$self->{skip_relationships};
+
$self->_check_back_compat;
+
$self;
}
@@ -429,9 +437,13 @@
if(!$self->skip_relationships) {
# The relationship loader needs a working schema
$self->{quiet} = 1;
+ local $self->{dump_directory} = $self->{temp_directory};
$self->_reload_classes(@tables);
$self->_load_relationships($_) for @tables;
$self->{quiet} = 0;
+
+ # Remove that temp dir from INC so it doesn't get reloaded
+ @INC = grep { $_ ne $self->{dump_directory} } @INC;
}
$self->_load_external($_)
@@ -523,6 +535,8 @@
my $schema_text =
qq|package $schema_class;\n\n|
+ . qq|# Created by DBIx::Class::Schema::Loader\n|
+ . qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|
. qq|use strict;\nuse warnings;\n\n|
. qq|use base '$schema_base_class';\n\n|;
@@ -550,6 +564,8 @@
foreach my $src_class (@classes) {
my $src_text =
qq|package $src_class;\n\n|
+ . qq|# Created by DBIx::Class::Schema::Loader\n|
+ . qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|
. qq|use strict;\nuse warnings;\n\n|
. qq|use base '$result_base_class';\n\n|;
@@ -560,6 +576,14 @@
}
+sub _sig_comment {
+ my ($self, $version, $ts) = @_;
+ return qq|\n\n# Created by DBIx::Class::Schema::Loader|
+ . qq| v| . $version
+ . q| @ | . $ts
+ . qq|\n# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:|;
+}
+
sub _write_classfile {
my ($self, $class, $text) = @_;
@@ -572,19 +596,28 @@
unlink($filename);
}
- my $custom_content = $self->_get_custom_content($class, $filename);
- $custom_content ||= qq|\n\n# You can replace this text with custom|
- . qq| content, and it will be preserved on regeneration|
- . qq|\n1;\n|;
+ my ($custom_content, $old_md5, $old_ver, $old_ts) = $self->_get_custom_content($class, $filename);
$text .= qq|$_\n|
for @{$self->{_dump_storage}->{$class} || []};
- $text .= qq|\n\n# Created by DBIx::Class::Schema::Loader|
- . qq| v| . $DBIx::Class::Schema::Loader::VERSION
- . q| @ | . POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
- . qq|\n# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:|;
+ # Check and see if the dump is infact differnt
+ my $compare_to;
+ if ($old_md5) {
+ $compare_to = $text . $self->_sig_comment($old_ver, $old_ts);
+
+
+ if (Digest::MD5::md5_base64($compare_to) eq $old_md5) {
+ return;
+ }
+ }
+
+ $text .= $self->_sig_comment(
+ $DBIx::Class::Schema::Loader::VERSION,
+ POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
+ );
+
open(my $fh, '>', $filename)
or croak "Cannot open '$filename' for writing: $!";
@@ -602,24 +635,36 @@
or croak "Error closing '$filename': $!";
}
+sub _default_custom_content {
+ return qq|\n\n# You can replace this text with custom|
+ . qq| content, and it will be preserved on regeneration|
+ . qq|\n1;\n|;
+}
+
sub _get_custom_content {
my ($self, $class, $filename) = @_;
- return if ! -f $filename;
+ return ($self->_default_custom_content) if ! -f $filename;
+
open(my $fh, '<', $filename)
or croak "Cannot open '$filename' for reading: $!";
my $mark_re =
qr{^(# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:)([A-Za-z0-9/+]{22})\n};
- my $found = 0;
my $buffer = '';
+ my ($md5, $ts, $ver);
while(<$fh>) {
- if(!$found && /$mark_re/) {
- $found = 1;
- $buffer .= $1;
+ if(!$md5 && /$mark_re/) {
+ $md5 = $2;
+ my $line = $1;
+
+ # Pull out the previous version and timestamp
+ ($ver, $ts) = $buffer =~ m/# Created by DBIx::Class::Schema::Loader v(.*?) @ (.*?)$/s;
+
+ $buffer .= $line;
croak "Checksum mismatch in '$filename'"
- if Digest::MD5::md5_base64($buffer) ne $2;
+ if Digest::MD5::md5_base64($buffer) ne $md5;
$buffer = '';
}
@@ -630,9 +675,12 @@
croak "Cannot not overwrite '$filename' without 'really_erase_my_files',"
. " it does not appear to have been generated by Loader"
- if !$found;
+ if !$md5;
- return $buffer;
+ # Default custom content:
+ $buffer ||= $self->_default_custom_content;
+
+ return ($buffer, $md5, $ver, $ts);
}
sub _use {
@@ -703,8 +751,15 @@
my $table_class = $self->classes->{$table};
my $table_moniker = $self->monikers->{$table};
- $self->_dbic_stmt($table_class,'table',$table);
+ my $table_name = $table;
+ my $name_sep = $self->schema->storage->sql_maker->name_sep;
+ if ($name_sep && $table_name =~ /\Q$name_sep\E/) {
+ $table_name = \ $self->_quote_table_name($table_name);
+ }
+
+ $self->_dbic_stmt($table_class,'table',$table_name);
+
my $cols = $self->_table_columns($table);
my $col_info;
eval { $col_info = $self->_columns_info_for($table) };
@@ -712,17 +767,26 @@
$self->_dbic_stmt($table_class,'add_columns',@$cols);
}
else {
- my %col_info_lc = map { lc($_), $col_info->{$_} } keys %$col_info;
+ if ($self->_is_case_sensitive) {
+ for my $col (keys %$col_info) {
+ $col_info->{$col}{accessor} = lc $col
+ if $col ne lc($col);
+ }
+ } else {
+ $col_info = { map { lc($_), $col_info->{$_} } keys %$col_info };
+ }
+
my $fks = $self->_table_fk_info($table);
+
for my $fkdef (@$fks) {
for my $col (@{ $fkdef->{local_columns} }) {
- $col_info_lc{$col}->{is_foreign_key} = 1;
+ $col_info->{$col}{is_foreign_key} = 1;
}
}
$self->_dbic_stmt(
$table_class,
'add_columns',
- map { $_, ($col_info_lc{$_}||{}) } @$cols
+ map { $_, ($col_info->{$_}||{}) } @$cols
);
}
@@ -846,6 +910,22 @@
push(@{$self->{_ext_storage}->{$class}}, $stmt);
}
+sub _quote_table_name {
+ my ($self, $table) = @_;
+
+ my $qt = $self->schema->storage->sql_maker->quote_char;
+
+ return $table unless $qt;
+
+ if (ref $qt) {
+ return $qt->[0] . $table . $qt->[1];
+ }
+
+ return $qt . $table . $qt;
+}
+
+sub _is_case_sensitive { 0 }
+
=head2 monikers
Returns a hashref of loaded table to moniker mappings. There will
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -2,11 +2,14 @@
use strict;
use warnings;
-use base 'DBIx::Class::Schema::Loader::DBI';
+use base qw/
+ DBIx::Class::Schema::Loader::DBI
+ DBIx::Class::Schema::Loader::DBI::Sybase::Common
+/;
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_06';
+our $VERSION = '0.04999_10';
=head1 NAME
@@ -31,14 +34,22 @@
my $self = shift;
$self->next::method(@_);
- $self->{db_schema} ||= 'dbo';
+ $self->{db_schema} ||= $self->_build_db_schema;
+ $self->_set_quote_char_and_name_sep;
}
-# DBD::Sybase doesn't implement get_info properly
-#sub _build_quoter { [qw/[ ]/] }
-sub _build_quoter { '"' }
-sub _build_namesep { '.' }
+# remove 'IDENTITY' from column data_type
+sub _columns_info_for {
+ my $self = shift;
+ my $result = $self->next::method(@_);
+ for my $col (keys %$result) {
+ $result->{$col}->{data_type} =~ s/\s* identity \s*//ix;
+ }
+
+ return $result;
+}
+
sub _table_pk_info {
my ($self, $table) = @_;
my $dbh = $self->schema->storage->dbh;
@@ -130,6 +141,10 @@
Justin Hunter C<justin.d.hunter at gmail.com>
+=head1 CONTRIBUTORS
+
+Rafael Kitover <rkitover at cpan.org>
+
=cut
1;
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_06';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_06';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
@@ -80,12 +80,12 @@
q{
SELECT constraint_name, acc.column_name
FROM all_constraints JOIN all_cons_columns acc USING (constraint_name)
- WHERE acc.table_name=? AND constraint_type='U'
+ WHERE acc.table_name=? and acc.owner = ? AND constraint_type='U'
ORDER BY acc.position
},
{}, 1);
- $sth->execute(uc $table);
+ $sth->execute(uc $table,$self->{db_schema} );
my %constr_names;
while(my $constr = $sth->fetchrow_arrayref) {
my $constr_name = lc $constr->[0];
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -7,7 +7,7 @@
use Text::Balanced qw( extract_bracketed );
use Class::C3;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
Added: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -0,0 +1,79 @@
+package DBIx::Class::Schema::Loader::DBI::Sybase::Common;
+
+use strict;
+use warnings;
+use Carp::Clan qw/^DBIx::Class/;
+use Class::C3;
+
+our $VERSION = '0.04999_10';
+
+=head1 NAME
+
+DBIx::Class::Schema::Loader::DBI::Sybase::Common - Common functions for Sybase
+and MSSQL
+
+=head1 DESCRIPTION
+
+See L<DBIx::Class::Schema::Loader::Base>.
+
+=cut
+
+# DBD::Sybase doesn't implement get_info properly
+sub _build_quoter { '"' }
+sub _build_namesep { '.' }
+
+sub _set_quote_char_and_name_sep {
+ my $self = shift;
+
+ $self->schema->storage->sql_maker->quote_char([qw/[ ]/])
+ unless $self->schema->storage->sql_maker->quote_char;
+
+ $self->schema->storage->sql_maker->name_sep('.')
+ unless $self->schema->storage->sql_maker->name_sep;
+}
+
+sub _build_db_schema {
+ my $self = shift;
+ my $dbh = $self->schema->storage->dbh;
+
+ local $dbh->{FetchHashKeyName} = 'NAME_lc';
+
+ my $test_table = "_loader_test_$$";
+
+ my $db_schema = 'dbo'; # default
+
+ eval {
+ $dbh->do("create table $test_table (id integer)");
+ my $sth = $dbh->prepare('sp_tables');
+ $sth->execute;
+ while (my $row = $sth->fetchrow_hashref) {
+ next unless $row->{table_name} eq $test_table;
+
+ $db_schema = $row->{table_owner};
+ last;
+ }
+ $sth->finish;
+ $dbh->do("drop table $test_table");
+ };
+ my $exception = $@;
+ eval { $dbh->do("drop table $test_table") };
+ carp "Could not determine db_schema, defaulting to $db_schema : $exception"
+ if $exception;
+
+ return $db_schema;
+}
+
+=head1 SEE ALSO
+
+L<DBIx::Class::Schema::Loader::DBI::Sybase>,
+L<DBIx::Class::Schema::Loader::DBI::MSSQL>,
+L<DBIx::Class::Schema::Loader::DBI>
+L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
+
+=head1 AUTHOR
+
+Rafael Kitover <rkitover at cpan.org>
+
+=cut
+
+1;
Added: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -0,0 +1,49 @@
+package DBIx::Class::Schema::Loader::DBI::Sybase::Microsoft_SQL_Server;
+
+use strict;
+use warnings;
+use base 'DBIx::Class::Schema::Loader::DBI::MSSQL';
+use Carp::Clan qw/^DBIx::Class/;
+use Class::C3;
+
+our $VERSION = '0.04999_10';
+
+=head1 NAME
+
+DBIx::Class::Schema::Loader::DBI::Sybase::Microsoft_SQL_Server - Subclass for
+using MSSQL through DBD::Sybase
+
+=head1 DESCRIPTION
+
+See L<DBIx::Class::Schema::Loader::Base>.
+
+Subclasses L<DBIx::Class::Schema::Loader::DBI::MSSQL>.
+
+=cut
+
+# Returns an array of table names
+sub _tables_list {
+ my $self = shift;
+
+ my ($table, $type) = @_ ? @_ : ('%', '%');
+
+ my $dbh = $self->schema->storage->dbh;
+ my @tables = $dbh->tables(undef, $self->db_schema, $table, $type);
+
+ return @tables;
+}
+
+=head1 SEE ALSO
+
+L<DBIx::Class::Schema::Loader::DBI::Sybase>,
+L<DBIx::Class::Schema::Loader::DBI::MSSQL>,
+L<DBIx::Class::Schema::Loader::DBI>
+L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
+
+=head1 AUTHOR
+
+Rafael Kitover <rkitover at cpan.org>
+
+=cut
+
+1;
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -2,11 +2,14 @@
use strict;
use warnings;
-use base 'DBIx::Class::Schema::Loader::DBI';
+use base qw/
+ DBIx::Class::Schema::Loader::DBI
+ DBIx::Class::Schema::Loader::DBI::Sybase::Common
+/;
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_06';
+our $VERSION = '0.04999_10';
=head1 NAME
@@ -27,11 +30,14 @@
=cut
+sub _is_case_sensitive { 1 }
+
sub _setup {
my $self = shift;
$self->next::method(@_);
- $self->{db_schema} ||= 'dbo';
+ $self->{db_schema} ||= $self->_build_db_schema;
+ $self->_set_quote_char_and_name_sep;
}
sub _rebless {
@@ -40,7 +46,8 @@
my $dbh = $self->schema->storage->dbh;
my $DBMS_VERSION = @{$dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2];
if ($DBMS_VERSION =~ /^Microsoft /i) {
- my $subclass = 'DBIx::Class::Schema::Loader::DBI::MSSQL';
+ $DBMS_VERSION =~ s/\s/_/g;
+ my $subclass = "DBIx::Class::Schema::Loader::DBI::Sybase::$DBMS_VERSION";
if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
bless $self, $subclass;
$self->_rebless;
@@ -67,7 +74,7 @@
my @keydata;
while (my $row = $sth->fetchrow_hashref) {
- push @keydata, lc $row->{column_name};
+ push @keydata, $row->{column_name};
}
return \@keydata;
@@ -76,19 +83,45 @@
sub _table_fk_info {
my ($self, $table) = @_;
+ # check if FK_NAME is supported
+
+ my $dbh = $self->schema->storage->dbh;
+ local $dbh->{FetchHashKeyName} = 'NAME_lc';
+ # hide "Object does not exist in this database." when trying to fetch fkeys
+ local $dbh->{syb_err_handler} = sub { return $_[0] == 17461 ? 0 : 1 };
+ my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
+ $sth->execute;
+ my $row = $sth->fetchrow_hashref;
+
+ return unless $row;
+
+ if (exists $row->{fk_name}) {
+ $sth->finish;
+ return $self->_table_fk_info_by_name($table);
+ }
+
+ $sth->finish;
+ return $self->_table_fk_info_builder($table);
+}
+
+sub _table_fk_info_by_name {
+ my ($self, $table) = @_;
my ($local_cols, $remote_cols, $remote_table, @rels);
+
my $dbh = $self->schema->storage->dbh;
+ local $dbh->{FetchHashKeyName} = 'NAME_lc';
# hide "Object does not exist in this database." when trying to fetch fkeys
- $dbh->{syb_err_handler} = sub { return 0 if $_[0] == 17461; };
- my $sth = $dbh->prepare(qq{sp_fkeys \@FKTABLE_NAME = '$table'});
+ local $dbh->{syb_err_handler} = sub { return $_[0] == 17461 ? 0 : 1 };
+ my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
- next unless $row->{FK_NAME};
- my $fk = $row->{FK_NAME};
- push @{$local_cols->{$fk}}, lc $row->{FKCOLUMN_NAME};
- push @{$remote_cols->{$fk}}, lc $row->{PKCOLUMN_NAME};
- $remote_table->{$fk} = $row->{PKTABLE_NAME};
+ my $fk = $row->{fk_name};
+ next unless defined $fk;
+
+ push @{$local_cols->{$fk}}, $row->{fkcolumn_name};
+ push @{$remote_cols->{$fk}}, $row->{pkcolumn_name};
+ $remote_table->{$fk} = $row->{pktable_name};
}
foreach my $fk (keys %$remote_table) {
@@ -102,19 +135,91 @@
return \@rels;
}
+sub _table_fk_info_builder {
+ my ($self, $table) = @_;
+
+ my $dbh = $self->schema->storage->dbh;
+ local $dbh->{FetchHashKeyName} = 'NAME_lc';
+ # hide "Object does not exist in this database." when trying to fetch fkeys
+ local $dbh->{syb_err_handler} = sub { return 0 if $_[0] == 17461; };
+ my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
+ $sth->execute;
+
+ my @fk_info;
+ while (my $row = $sth->fetchrow_hashref) {
+ (my $ksq = $row->{key_seq}) =~ s/\s+//g;
+
+ my @keys = qw/pktable_name pkcolumn_name fktable_name fkcolumn_name/;
+ my %ds;
+ @ds{@keys} = @{$row}{@keys};
+ $ds{key_seq} = $ksq;
+
+ push @{ $fk_info[$ksq] }, \%ds;
+ }
+
+ my $max_keys = $#fk_info;
+ my @rels;
+ for my $level (reverse 1 .. $max_keys) {
+ my @level_rels;
+ $level_rels[$level] = splice @fk_info, $level, 1;
+ my $count = @{ $level_rels[$level] };
+
+ for my $sub_level (reverse 1 .. $level-1) {
+ my $total = @{ $fk_info[$sub_level] };
+
+ $level_rels[$sub_level] = [
+ splice @{ $fk_info[$sub_level] }, $total-$count, $count
+ ];
+ }
+
+ while (1) {
+ my @rel = map shift @$_, @level_rels[1..$level];
+
+ last unless defined $rel[0];
+
+ my @local_columns = map $_->{fkcolumn_name}, @rel;
+ my @remote_columns = map $_->{pkcolumn_name}, @rel;
+ my $remote_table = $rel[0]->{pktable_name};
+
+ push @rels, {
+ local_columns => \@local_columns,
+ remote_columns => \@remote_columns,
+ remote_table => $remote_table
+ };
+ }
+ }
+
+ return \@rels;
+}
+
sub _table_uniq_info {
my ($self, $table) = @_;
+ local $SIG{__WARN__} = sub {};
+
my $dbh = $self->schema->storage->dbh;
+ local $dbh->{FetchHashKeyName} = 'NAME_lc';
my $sth = $dbh->prepare(qq{sp_helpconstraint \@objname='$table', \@nomsg='nomsg'});
- $sth->execute;
+ eval { $sth->execute };
+ return if $@;
my $constraints;
while (my $row = $sth->fetchrow_hashref) {
- my $type = $row->{constraint_type} || '';
- if ($type =~ /^unique/i) {
- my $name = lc $row->{constraint_name};
- push @{$constraints->{$name}}, ( split /,/, lc $row->{constraint_keys} );
+ if (exists $row->{constraint_type}) {
+ my $type = $row->{constraint_type} || '';
+ if ($type =~ /^unique/i) {
+ my $name = $row->{constraint_name};
+ push @{$constraints->{$name}},
+ ( split /,/, $row->{constraint_keys} );
+ }
+ } else {
+ my $def = $row->{definition} || next;
+ next unless $def =~ /^unique/i;
+ my $name = $row->{name};
+ my ($keys) = $def =~ /\((.*)\)/;
+ $keys =~ s/\s*//g;
+ my @keys = split /,/ => $keys;
+ push @{$constraints->{$name}}, @keys;
}
}
@@ -148,6 +253,10 @@
Justin Hunter C<justin.d.hunter at gmail.com>
+=head1 CONTRIBUTORS
+
+Rafael Kitover <rkitover at cpan.org>
+
=cut
1;
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -1,7 +1,7 @@
package DBIx::Class::Schema::Loader::DBI::Writing;
use strict;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
# Empty. POD only.
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Class::C3;
use Carp::Clan qw/^DBIx::Class/;
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
@@ -90,9 +90,15 @@
my $dbh = $self->schema->storage->dbh;
my @tables = $dbh->tables(undef, $self->db_schema, $table, $type);
- s/\Q$self->{_quoter}\E//g for @tables;
- s/^.*\Q$self->{_namesep}\E// for @tables;
+ my $qt = qr/\Q$self->{_quoter}\E/;
+ if ($self->{_quoter} && $tables[0] =~ /$qt/) {
+ s/.* $qt (?= .* $qt)//xg for @tables;
+ } else {
+ s/^.*\Q$self->{_namesep}\E// for @tables;
+ }
+ s/$qt//g for @tables;
+
return @tables;
}
@@ -117,10 +123,13 @@
my $dbh = $self->schema->storage->dbh;
if($self->{db_schema}) {
- $table = $self->{db_schema} . $self->{_namesep} . $table;
+ $table = $self->{db_schema} . $self->{_namesep} .
+ $self->_quote_table_name($table);
+ } else {
+ $table = $self->_quote_table_name($table);
}
- my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
+ my $sth = $dbh->prepare($self->schema->storage->sql_maker->select(\$table, undef, \'1 = 0'));
$sth->execute;
my $retval = \@{$sth->{NAME_lc}};
$sth->finish;
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -6,7 +6,7 @@
use Carp::Clan qw/^DBIx::Class/;
use Lingua::EN::Inflect::Number ();
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
=head1 NAME
Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -10,7 +10,7 @@
# Always remember to do all digits for the version even if they're 0
# i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
# brain damage and presumably various other packaging systems too
-our $VERSION = '0.04999_07';
+our $VERSION = '0.04999_10';
__PACKAGE__->mk_classaccessor('_loader_args' => {});
__PACKAGE__->mk_classaccessors(qw/dump_to_dir _loader_invoked _loader loader_class/);
Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/11mysql_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/11mysql_common.t 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/11mysql_common.t 2009-11-01 09:19:27 UTC (rev 7834)
@@ -53,10 +53,10 @@
'MySQL ENUM values');
$rs = $schema->resultset($monikers->{mysql_loader_test2});
- my $column_info = $rs->result_source->column_info('somedate');
- my $default = $column_info->{default_value};
- ok (ref($default) eq 'SCALAR'),
- 'CURRENT_TIMESTAMP default_value is a scalar ref';
+ $column_info = $rs->result_source->column_info('somedate');
+ my $default = $column_info->{default_value};
+ ok ((ref($default) eq 'SCALAR'),
+ 'CURRENT_TIMESTAMP default_value is a scalar ref');
like $$default, qr/^CURRENT_TIMESTAMP\z/i,
'CURRENT_TIMESTAMP default eq "CURRENT_TIMESTAMP"';
},
Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/13db2_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/13db2_common.t 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/13db2_common.t 2009-11-01 09:19:27 UTC (rev 7834)
@@ -12,6 +12,7 @@
dsn => $dsn,
user => $user,
password => $password,
+ null => '',
);
if( !$dsn || !$user ) {
Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/15sybase_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/15sybase_common.t 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/15sybase_common.t 2009-11-01 09:19:27 UTC (rev 7834)
@@ -2,13 +2,15 @@
use lib qw(t/lib);
use dbixcsl_common_tests;
+# You need the sybase branch of DBIx::Class, from:
+# http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/branches/sybase
+
my $dsn = $ENV{DBICTEST_SYBASE_DSN} || '';
my $user = $ENV{DBICTEST_SYBASE_USER} || '';
my $password = $ENV{DBICTEST_SYBASE_PASS} || '';
my $tester = dbixcsl_common_tests->new(
- vendor => 'Sybase',
- quote_char => [qw/[ ]/],
+ vendor => 'sybase',
auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
dsn => $dsn,
user => $user,
Added: branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_common.t (rev 0)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_common.t 2009-11-01 09:19:27 UTC (rev 7834)
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+
+# use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else
+BEGIN {
+ if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) {
+ unshift @INC, $_ for split /:/, $lib_dirs;
+ }
+}
+
+use lib qw(t/lib);
+use dbixcsl_common_tests;
+use dbixcsl_mssql_extra_tests;
+
+my $dsn = $ENV{DBICTEST_MSSQL_DSN} || '';
+my $user = $ENV{DBICTEST_MSSQL_USER} || '';
+my $password = $ENV{DBICTEST_MSSQL_PASS} || '';
+
+my $tester = dbixcsl_common_tests->new(
+ vendor => 'mssql',
+ auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
+ dsn => $dsn,
+ user => $user,
+ password => $password,
+ extra => dbixcsl_mssql_extra_tests->extra,
+);
+
+if( !$dsn || !$user ) {
+ $tester->skip_tests('You need to set the DBICTEST_MSSQL_DSN, _USER, and _PASS environment variables');
+}
+else {
+ $tester->run_tests();
+}
Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_odbc_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_odbc_common.t 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/16mssql_odbc_common.t 2009-11-01 09:19:27 UTC (rev 7834)
@@ -1,18 +1,19 @@
use strict;
use lib qw(t/lib);
use dbixcsl_common_tests;
+use dbixcsl_mssql_extra_tests;
my $dsn = $ENV{DBICTEST_MSSQL_ODBC_DSN} || '';
my $user = $ENV{DBICTEST_MSSQL_ODBC_USER} || '';
my $password = $ENV{DBICTEST_MSSQL_ODBC_PASS} || '';
my $tester = dbixcsl_common_tests->new(
- vendor => 'Microsoft',
- quote_char => [qw/[ ]/],
+ vendor => 'mssql',
auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
dsn => $dsn,
user => $user,
password => $password,
+ extra => dbixcsl_mssql_extra_tests->extra,
);
if( !$dsn || !$user ) {
Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm 2009-11-01 05:51:33 UTC (rev 7833)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -27,6 +27,9 @@
# Only MySQL uses this
$self->{innodb} ||= '';
+
+ # DB2 doesn't support this
+ $self->{null} = 'NULL' unless defined $self->{null};
$self->{verbose} = $ENV{TEST_VERBOSE} || 0;
@@ -55,7 +58,12 @@
$self->create();
- my @connect_info = ( $self->{dsn}, $self->{user}, $self->{password} );
+ my @connect_info = (
+ $self->{dsn},
+ $self->{user},
+ $self->{password},
+ $self->{connect_info_opts},
+ );
# First, with in-memory classes
my $schema_class = $self->setup_schema(@connect_info);
@@ -72,7 +80,8 @@
my $debug = ($self->{verbose} > 1) ? 1 : 0;
my %loader_opts = (
- constraint => qr/^(?:\S+\.)?(?:$self->{vendor}_)?loader_test[0-9]+s?$/i,
+ constraint =>
+ qr/^(?:\S+\.)?(?:$self->{vendor}_)?loader_test[0-9]+(?!.*_)/i,
relationships => 1,
additional_classes => 'TestAdditional',
additional_base_classes => 'TestAdditionalBase',
@@ -391,7 +400,11 @@
isa_ok( $rs_rel4->first, $class4);
# find on multi-col pk
- my $obj5 = $rsobj5->find({id1 => 1, id2 => 1});
+ my $obj5 =
+ eval { $rsobj5->find({id1 => 1, iD2 => 1}) } ||
+ eval { $rsobj5->find({id1 => 1, id2 => 1}) };
+ die $@ if $@;
+
is( $obj5->id2, 1, "Find on multi-col PK" );
# mulit-col fk def
@@ -401,8 +414,11 @@
ok($class6->column_info('loader_test2_id')->{is_foreign_key}, 'Foreign key detected');
ok($class6->column_info('id')->{is_foreign_key}, 'Foreign key detected');
- ok($class6->column_info('id2')->{is_foreign_key}, 'Foreign key detected');
+ my $id2_info = eval { $class6->column_info('id2') } ||
+ $class6->column_info('Id2');
+ ok($id2_info->{is_foreign_key}, 'Foreign key detected');
+
# fk that references a non-pk key (UNIQUE)
my $obj8 = $rsobj8->find(1);
isa_ok( $obj8->loader_test7, $class7);
@@ -512,52 +528,46 @@
}
# from Chisel's tests...
- SKIP: {
- if($self->{vendor} =~ /sqlite/i) {
- skip 'SQLite cannot do the advanced tests', 10;
- }
+ my $moniker10 = $monikers->{loader_test10};
+ my $class10 = $classes->{loader_test10};
+ my $rsobj10 = $conn->resultset($moniker10);
- my $moniker10 = $monikers->{loader_test10};
- my $class10 = $classes->{loader_test10};
- my $rsobj10 = $conn->resultset($moniker10);
+ my $moniker11 = $monikers->{loader_test11};
+ my $class11 = $classes->{loader_test11};
+ my $rsobj11 = $conn->resultset($moniker11);
- my $moniker11 = $monikers->{loader_test11};
- my $class11 = $classes->{loader_test11};
- my $rsobj11 = $conn->resultset($moniker11);
+ isa_ok( $rsobj10, "DBIx::Class::ResultSet" );
+ isa_ok( $rsobj11, "DBIx::Class::ResultSet" );
- isa_ok( $rsobj10, "DBIx::Class::ResultSet" );
- isa_ok( $rsobj11, "DBIx::Class::ResultSet" );
+ ok($class10->column_info('loader_test11')->{is_foreign_key}, 'Foreign key detected');
+ ok($class11->column_info('loader_test10')->{is_foreign_key}, 'Foreign key detected');
- ok($class10->column_info('loader_test11')->{is_foreign_key}, 'Foreign key detected');
- ok($class11->column_info('loader_test10')->{is_foreign_key}, 'Foreign key detected');
+ my $obj10 = $rsobj10->create({ subject => 'xyzzy' });
- my $obj10 = $rsobj10->create({ subject => 'xyzzy' });
+ $obj10->update();
+ ok( defined $obj10, 'Create row' );
- $obj10->update();
- ok( defined $obj10, 'Create row' );
+ my $obj11 = $rsobj11->create({ loader_test10 => $obj10->id() });
+ $obj11->update();
+ ok( defined $obj11, 'Create related row' );
- my $obj11 = $rsobj11->create({ loader_test10 => $obj10->id() });
- $obj11->update();
- ok( defined $obj11, 'Create related row' );
+ eval {
+ my $obj10_2 = $obj11->loader_test10;
+ $obj10_2->loader_test11( $obj11->id11() );
+ $obj10_2->update();
+ };
+ ok(!$@, "Setting up circular relationship");
- eval {
- my $obj10_2 = $obj11->loader_test10;
- $obj10_2->loader_test11( $obj11->id11() );
- $obj10_2->update();
- };
- ok(!$@, "Setting up circular relationship");
+ SKIP: {
+ skip 'Previous eval block failed', 3 if $@;
+
+ my $results = $rsobj10->search({ subject => 'xyzzy' });
+ is( $results->count(), 1, 'No duplicate row created' );
- SKIP: {
- skip 'Previous eval block failed', 3 if $@;
-
- my $results = $rsobj10->search({ subject => 'xyzzy' });
- is( $results->count(), 1, 'No duplicate row created' );
-
- my $obj10_3 = $results->first();
- isa_ok( $obj10_3, $class10 );
- is( $obj10_3->loader_test11()->id(), $obj11->id(),
- 'Circular rel leads back to same row' );
- }
+ my $obj10_3 = $results->first();
+ isa_ok( $obj10_3, $class10 );
+ is( $obj10_3->loader_test11()->id(), $obj11->id(),
+ 'Circular rel leads back to same row' );
}
SKIP: {
@@ -754,11 +764,11 @@
id1 INTEGER NOT NULL,
iD2 INTEGER NOT NULL,
dat VARCHAR(8),
- PRIMARY KEY (id1,id2)
+ PRIMARY KEY (id1,iD2)
) $self->{innodb}
},
- q{ INSERT INTO loader_test5 (id1,id2,dat) VALUES (1,1,'aaa') },
+ q{ INSERT INTO loader_test5 (id1,iD2,dat) VALUES (1,1,'aaa') },
qq{
CREATE TABLE loader_test6 (
@@ -771,7 +781,7 @@
) $self->{innodb}
},
- (q{ INSERT INTO loader_test6 (id, id2,loader_test2_id,dat) } .
+ (q{ INSERT INTO loader_test6 (id, Id2,loader_test2_id,dat) } .
q{ VALUES (1, 1,1,'aaa') }),
qq{
@@ -953,7 +963,7 @@
CREATE TABLE loader_test32 (
id INTEGER NOT NULL PRIMARY KEY,
rel1 INTEGER NOT NULL,
- rel2 INTEGER,
+ rel2 INTEGER $self->{null},
FOREIGN KEY (rel1) REFERENCES loader_test31(id),
FOREIGN KEY (rel2) REFERENCES loader_test31(id)
) $self->{innodb}
@@ -973,7 +983,7 @@
CREATE TABLE loader_test34 (
id INTEGER NOT NULL PRIMARY KEY,
rel1 INTEGER NOT NULL,
- rel2 INTEGER,
+ rel2 INTEGER $self->{null},
FOREIGN KEY (id,rel1) REFERENCES loader_test33(id1,id2),
FOREIGN KEY (id,rel2) REFERENCES loader_test33(id1,id2)
) $self->{innodb}
@@ -986,7 +996,7 @@
CREATE TABLE loader_test10 (
id10 $self->{auto_inc_pk},
subject VARCHAR(8),
- loader_test11 INTEGER
+ loader_test11 INTEGER $self->{null}
) $self->{innodb}
},
$make_auto_inc->(qw/loader_test10 id10/),
@@ -995,7 +1005,7 @@
CREATE TABLE loader_test11 (
id11 $self->{auto_inc_pk},
message VARCHAR(8) DEFAULT 'foo',
- loader_test10 INTEGER,
+ loader_test10 INTEGER $self->{null},
FOREIGN KEY (loader_test10) REFERENCES loader_test10 (id10)
) $self->{innodb}
},
@@ -1006,6 +1016,29 @@
q{ REFERENCES loader_test11 (id11) }),
);
+ my @statements_advanced_sqlite = (
+ qq{
+ CREATE TABLE loader_test10 (
+ id10 $self->{auto_inc_pk},
+ subject VARCHAR(8)
+ ) $self->{innodb}
+ },
+ $make_auto_inc->(qw/loader_test10 id10/),
+
+ qq{
+ CREATE TABLE loader_test11 (
+ id11 $self->{auto_inc_pk},
+ message VARCHAR(8) DEFAULT 'foo',
+ loader_test10 INTEGER $self->{null},
+ FOREIGN KEY (loader_test10) REFERENCES loader_test10 (id10)
+ ) $self->{innodb}
+ },
+ $make_auto_inc->(qw/loader_test11 id11/),
+
+ (q{ ALTER TABLE loader_test10 ADD COLUMN } .
+ q{ loader_test11 INTEGER REFERENCES loader_test11 (id11) }),
+ );
+
my @statements_inline_rels = (
qq{
CREATE TABLE loader_test12 (
@@ -1067,7 +1100,10 @@
# to test one for mysql, which works on everyone else...
# this all needs to be refactored anyways.
$dbh->do($_) for (@statements_reltests);
- unless($self->{vendor} =~ /sqlite/i) {
+ if($self->{vendor} =~ /sqlite/i) {
+ $dbh->do($_) for (@statements_advanced_sqlite);
+ }
+ else {
$dbh->do($_) for (@statements_advanced);
}
unless($self->{no_inline_rels}) {
@@ -1159,16 +1195,15 @@
unless($self->{skip_rels}) {
$dbh->do("DROP TABLE $_") for (@tables_reltests);
- unless($self->{vendor} =~ /sqlite/i) {
- if($self->{vendor} =~ /mysql/i) {
- $dbh->do($drop_fk_mysql);
- }
- else {
- $dbh->do($drop_fk);
- }
- $dbh->do("DROP TABLE $_") for (@tables_advanced);
- $dbh->do($_) for map { $drop_auto_inc->(@$_) } @tables_advanced_auto_inc;
+ if($self->{vendor} =~ /mysql/i) {
+ $dbh->do($drop_fk_mysql);
}
+ else {
+ $dbh->do($drop_fk);
+ }
+ $dbh->do("DROP TABLE $_") for (@tables_advanced);
+ $dbh->do($_) for map { $drop_auto_inc->(@$_) } @tables_advanced_auto_inc;
+
unless($self->{no_inline_rels}) {
$dbh->do("DROP TABLE $_") for (@tables_inline_rels);
}
@@ -1184,8 +1219,10 @@
sub DESTROY {
my $self = shift;
- $self->drop_tables if $self->{_created};
- rmtree $DUMP_DIR;
+ unless ($ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {
+ $self->drop_tables if $self->{_created};
+ rmtree $DUMP_DIR
+ }
}
1;
Added: branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm 2009-11-01 09:19:27 UTC (rev 7834)
@@ -0,0 +1,54 @@
+package dbixcsl_mssql_extra_tests;
+
+use Test::More;
+
+my $vendor = 'mssql';
+
+sub vendor {
+ shift;
+ $vendor = shift;
+}
+
+sub extra { +{
+ create => [
+ qq{
+ CREATE TABLE [${vendor}_loader_test1.dot] (
+ id INT IDENTITY NOT NULL PRIMARY KEY,
+ dat VARCHAR(8)
+ )
+ },
+ ],
+ drop => [ "[${vendor}_loader_test1.dot]" ],
+ count => 6,
+ run => sub {
+ my ($schema, $monikers, $classes) = @_;
+
+# Test that the table above (with '.' in name) gets loaded correctly.
+ my $vendor_titlecased = "\u\L$vendor";
+
+ ok((my $rs = eval {
+ $schema->resultset("${vendor_titlecased}LoaderTest1Dot") }),
+ 'got a resultset');
+
+ ok((my $from = eval { $rs->result_source->from }),
+ 'got an $rsrc->from');
+
+ is ref($from), 'SCALAR', '->table is a scalar ref';
+
+ is eval { $$from }, "[${vendor}_loader_test1.dot]",
+ '->table name is correct';
+
+# Test that identity columns do not have 'identity' in the data_type, and do
+# have is_auto_increment.
+ my $identity_col_info = $schema->resultset('LoaderTest10')
+ ->result_source->column_info('id10');
+
+ is $identity_col_info->{data_type}, 'int',
+ q{'INT IDENTITY' column has data_type => 'int'};
+
+ is $identity_col_info->{is_auto_increment}, 1,
+ q{'INT IDENTITY' column has is_auto_increment => 1};
+ },
+}}
+
+1;
More information about the Bast-commits
mailing list