[Bast-commits] r6644 - in DBIx-Class/0.08/branches/on_connect_call:
. lib/DBIx lib/DBIx/Class lib/DBIx/Class/InflateColumn
lib/DBIx/Class/Manual lib/DBIx/Class/Storage
lib/DBIx/Class/Storage/DBI t t/inflate t/lib/DBICNSTest/Bogus
t/lib/DBICTest/Schema t/update
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Fri Jun 12 00:06:35 GMT 2009
Author: caelum
Date: 2009-06-12 00:06:35 +0000 (Fri, 12 Jun 2009)
New Revision: 6644
Added:
DBIx-Class/0.08/branches/on_connect_call/t/inflate/
DBIx-Class/0.08/branches/on_connect_call/t/inflate/core.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_mysql.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_pg.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/file_column.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/hri.t
DBIx-Class/0.08/branches/on_connect_call/t/inflate/serialize.t
DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICNSTest/Bogus/B.pm
DBIx-Class/0.08/branches/on_connect_call/t/update/
DBIx-Class/0.08/branches/on_connect_call/t/update/type_aware.t
Removed:
DBIx-Class/0.08/branches/on_connect_call/t/68inflate.t
DBIx-Class/0.08/branches/on_connect_call/t/68inflate_resultclass_hashrefinflator.t
DBIx-Class/0.08/branches/on_connect_call/t/68inflate_serialize.t
DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t
DBIx-Class/0.08/branches/on_connect_call/t/96file_column.t
Modified:
DBIx-Class/0.08/branches/on_connect_call/
DBIx-Class/0.08/branches/on_connect_call/Changes
DBIx-Class/0.08/branches/on_connect_call/Makefile.PL
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/InflateColumn/DateTime.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Manual/Cookbook.pod
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI/SQLite.pm
DBIx-Class/0.08/branches/on_connect_call/t/36datetime.t
DBIx-Class/0.08/branches/on_connect_call/t/60core.t
DBIx-Class/0.08/branches/on_connect_call/t/74mssql.t
DBIx-Class/0.08/branches/on_connect_call/t/95sql_maker.t
DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/Event.pm
DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZ.pm
DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZDeprecated.pm
Log:
r5467 at hlagh (orig r6614): ribasushi | 2009-06-11 05:29:48 -0700
Move around inflation tests
r5468 at hlagh (orig r6615): ribasushi | 2009-06-11 05:32:07 -0700
explicitly remove manifest on author mode make
r5469 at hlagh (orig r6616): ribasushi | 2009-06-11 06:02:41 -0700
IC::DT changes:
Switch SQLite storage to DT::F::SQLite
Fix exception when undef_if_invalid and timezone are both set on a column
Split t/89inflate_datetime into separate tests
Adjust makefile author dependencies
r5470 at hlagh (orig r6617): ribasushi | 2009-06-11 06:07:41 -0700
Move file_column test to inflate/ too
r5472 at hlagh (orig r6620): ribasushi | 2009-06-11 07:16:20 -0700
r5713 at Thesaurus (orig r5712): ribasushi | 2009-03-08 23:53:28 +0100
Branch for datatype-aware updates
r6604 at Thesaurus (orig r6603): ribasushi | 2009-06-10 18:08:25 +0200
Test for type-aware update
r6607 at Thesaurus (orig r6606): ribasushi | 2009-06-10 19:57:04 +0200
Datatype aware update works
r6609 at Thesaurus (orig r6608): ribasushi | 2009-06-10 20:06:40 +0200
Whoops
r6614 at Thesaurus (orig r6613): ribasushi | 2009-06-11 09:23:54 +0200
Add attribute doc
r6620 at Thesaurus (orig r6619): ribasushi | 2009-06-11 16:15:53 +0200
Use equality, not comparison
r5474 at hlagh (orig r6622): ribasushi | 2009-06-11 07:21:53 -0700
Changes
r5486 at hlagh (orig r6635): ribasushi | 2009-06-11 12:29:10 -0700
Release 0.08105
r5487 at hlagh (orig r6636): frew | 2009-06-11 13:02:11 -0700
Escape filename so that t\9... won't look like octal
r5488 at hlagh (orig r6637): ribasushi | 2009-06-11 13:09:55 -0700
Adjust tests for the DT::F::MySQL -> DT::F::SQLite change
r5489 at hlagh (orig r6638): arcanez | 2009-06-11 13:29:53 -0700
cookbook tweak for count distinct
r5490 at hlagh (orig r6639): ribasushi | 2009-06-11 14:39:12 -0700
Factor out as_query properly
r5491 at hlagh (orig r6640): ribasushi | 2009-06-11 14:50:41 -0700
Release 0.08106
r5493 at hlagh (orig r6642): caelum | 2009-06-11 16:48:28 -0700
add support for DBICTEST_MSSQL_PERL5LIB to 74mssql.t
Property changes on: DBIx-Class/0.08/branches/on_connect_call
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/diamond_relationships:6310
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/joined_count:6323
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/mystery_join:6589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/order_by_refactor:6475
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rsrc_in_storage:6577
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/top_limit_altfix:6429
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/diamond_relationships:6310
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/joined_count:6323
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/mystery_join:6589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/order_by_refactor:6475
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rsrc_in_storage:6577
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/top_limit_altfix:6429
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/type_aware_update:6619
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:6642
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/on_connect_call/Changes
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/Changes 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/Changes 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,5 +1,17 @@
Revision history for DBIx::Class
+0.08106 2009-06-11 21:42:00 (UTC)
+ - Switched SQLite storage driver to DateTime::Format::SQLite
+ (proper timezone handling)
+ - Fix more test problems
+
+0.08105 2009-06-11 19:04:00 (UTC)
+ - Update of numeric columns now properly uses != to determine
+ dirtyness instead of the usual eq
+ - Fixes to IC::DT tests
+ - Fixed exception when undef_if_invalid and timezone are both set on
+ an invalid datetime column
+
0.08104 2009-06-10 13:38:00 (UTC)
- order_by now can take \[$sql, @bind] as in
order_by => { -desc => \['colA LIKE ?', 'somestring'] }
Modified: DBIx-Class/0.08/branches/on_connect_call/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/Makefile.PL 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/Makefile.PL 2009-06-12 00:06:35 UTC (rev 6644)
@@ -73,12 +73,17 @@
'Test::Memory::Cycle' => 0,
'Devel::Cycle' => 1.10,
+ # t/inflate/datetime*.t
+ # t/72.pg
+ # t/36datetime.t
# t/60core.t
+ 'DateTime::Format::SQLite' => 0,
'DateTime::Format::MySQL' => 0,
-
- # t/89inflate_datetime.t
'DateTime::Format::Pg' => 0,
+ # t/96_is_deteministic_value.t
+ 'DateTime::Format::Strptime' => 0,
+
# t/72pg.t
$ENV{DBICTEST_PG_DSN}
? ('Sys::SigAction'=> 0)
@@ -92,8 +97,6 @@
'namespace::clean' => 0.11,
'Hash::Merge', => 0.11,
- # t/96_is_deteministic_value.t
- 'DateTime::Format::Strptime' => 0,
);
if ($Module::Install::AUTHOR) {
@@ -112,13 +115,17 @@
build_requires ($module => $force_requires_if_author{$module});
}
+ print "Regenerating README\n";
system('pod2text lib/DBIx/Class.pm > README');
+
+ if (-f 'MANIFEST') {
+ print "Removing MANIFEST\n";
+ unlink 'MANIFEST';
+ }
}
-auto_provides;
+auto_install();
-auto_install;
-
WriteAll();
# Re-write META.yml to _exclude_ all forced requires (we do not want to ship this)
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -148,9 +148,13 @@
{
inflate => sub {
my ($value, $obj) = @_;
+
my $dt = eval { $obj->_inflate_to_datetime( $value, \%info ) };
- $self->throw_exception ("Error while inflating ${value} for ${column} on ${self}: $@")
- if $@ and not $undef_if_invalid;
+ if (my $err = $@ ) {
+ return undef if ($undef_if_invalid);
+ $self->throw_exception ("Error while inflating ${value} for ${column} on ${self}: $err");
+ }
+
$dt->set_time_zone($timezone) if $timezone;
$dt->set_locale($locale) if $locale;
return $dt;
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Manual/Cookbook.pod
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Manual/Cookbook.pod 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Manual/Cookbook.pod 2009-06-12 00:06:35 UTC (rev 6644)
@@ -279,7 +279,7 @@
my $count = $rs->count;
# Equivalent SQL:
- # SELECT COUNT( DISTINCT( me.name ) ) FROM artist me
+ # SELECT COUNT( * ) FROM (SELECT me.name FROM artist me GROUP BY me.name) count_subq:
=head2 Grouping results
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSet.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSet.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1927,7 +1927,13 @@
sub as_query {
my $self = shift;
- return $self->result_source->storage->as_query($self->_resolved_attrs);
+
+ my $attrs = $self->_resolved_attrs_copy;
+
+ my ($sqlbind, $bind_attrs) = $self->result_source->storage
+ ->_select_args_to_query ($attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs);
+
+ return $sqlbind;
}
=head2 find_or_new
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSource.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/ResultSource.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -116,6 +116,18 @@
when cloning objects using L<DBIx::Class::Row/copy>. It is also used by
L<DBIx::Class::Schema/deploy>.
+=item is_numeric
+
+Set this to a true or false value (not C<undef>) to explicitly specify
+if this column contains numeric data. This controls how set_column
+decides whether to consider a column dirty after an update: if
+C<is_numeric> is true a numeric comparison C<< != >> will take place
+instead of the usual C<eq>
+
+If not specified the storage class will attempt to figure this out on
+first access to the column, based on the column C<data_type>. The
+result will be cached in this attribute.
+
=item is_foreign_key
Set this to a true value for a column that contains a key from a
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Row.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Row.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -769,9 +769,40 @@
my $old_value = $self->get_column($column);
$self->store_column($column, $new_value);
- $self->{_dirty_columns}{$column} = 1
- if (defined $old_value xor defined $new_value) || (defined $old_value && $old_value ne $new_value);
+ my $dirty;
+ if (defined $old_value xor defined $new_value) {
+ $dirty = 1;
+ }
+ elsif (not defined $old_value) { # both undef
+ $dirty = 0;
+ }
+ elsif ($old_value eq $new_value) {
+ $dirty = 0;
+ }
+ else { # do a numeric comparison if datatype allows it
+ my $colinfo = $self->column_info ($column);
+
+ # cache for speed
+ if (not defined $colinfo->{is_numeric}) {
+ $colinfo->{is_numeric} =
+ $self->result_source->schema->storage->is_datatype_numeric ($colinfo->{data_type})
+ ? 1
+ : 0
+ ;
+ }
+
+ if ($colinfo->{is_numeric}) {
+ $dirty = $old_value != $new_value;
+ }
+ else {
+ $dirty = 1;
+ }
+ }
+
+ # sadly the update code just checks for keys, not for their value
+ $self->{_dirty_columns}{$column} = 1 if $dirty;
+
# XXX clear out the relation cache for this column
delete $self->{related_resultsets}{$column};
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI/SQLite.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI/SQLite.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI/SQLite.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -45,6 +45,8 @@
return $backupfile;
}
+sub datetime_parser_type { return "DateTime::Format::SQLite"; }
+
1;
=head1 NAME
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class/Storage/DBI.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1044,38 +1044,7 @@
return ($sql, \@bind);
}
-=head2 as_query
-=over 4
-
-=item Arguments: $rs_attrs
-
-=item Return Value: \[ $sql, @bind ]
-
-=back
-
-Returns the SQL statement and bind vars that would result from the given
-ResultSet attributes (does not actually run a query)
-
-=cut
-
-sub as_query {
- my ($self, $rs_attr) = @_;
-
- my $sql_maker = $self->sql_maker;
- local $sql_maker->{for};
-
- # my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset) = $self->_select_args(...);
- my @args = $self->_select_args($rs_attr->{from}, $rs_attr->{select}, $rs_attr->{where}, $rs_attr);
-
- # my ($sql, $bind) = $self->_prep_for_execute($op, $bind, $ident, [ $select, $cond, $order, $rows, $offset ]);
- my ($sql, $bind) = $self->_prep_for_execute(
- @args[0 .. 2],
- [ @args[4 .. $#args] ],
- );
- return \[ "($sql)", @{ $bind || [] }];
-}
-
sub _fix_bind_params {
my ($self, @bind) = @_;
@@ -1361,6 +1330,23 @@
return $self->_execute($self->_select_args(@_));
}
+sub _select_args_to_query {
+ my $self = shift;
+
+ my $sql_maker = $self->sql_maker;
+ local $sql_maker->{for};
+
+ # my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset)
+ # = $self->_select_args($ident, $select, $cond, $attrs);
+ my ($op, $bind, $ident, $bind_attrs, @args) =
+ $self->_select_args(@_);
+
+ # my ($sql, $bind) = $self->_prep_for_execute($op, $bind, $ident, [ $select, $cond, $order, $rows, $offset ]);
+ my ($sql, $prepared_bind) = $self->_prep_for_execute($op, $bind, $ident, \@args);
+
+ return \[ "($sql)", @{ $prepared_bind || [] }];
+}
+
sub _select_args {
my ($self, $ident, $select, $condition, $attrs) = @_;
@@ -1693,6 +1679,27 @@
return;
}
+=head2 is_datatype_numeric
+
+Given a datatype from column_info, returns a boolean value indicating if
+the current RDBMS considers it a numeric value. This controls how
+L<DBIx::Class::Row/set_column> decides whether to mark the column as
+dirty - when the datatype is deemed numeric a C<< != >> comparison will
+be performed instead of the usual C<eq>.
+
+=cut
+
+sub is_datatype_numeric {
+ my ($self, $dt) = @_;
+
+ return 0 unless $dt;
+
+ return $dt =~ /^ (?:
+ numeric | int(?:eger)? | (?:tiny|small|medium|big)int | dec(?:imal)? | real | float | double (?: \s+ precision)? | (?:big)?serial
+ ) $/ix;
+}
+
+
=head2 create_ddl_dir (EXPERIMENTAL)
=over 4
Modified: DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/lib/DBIx/Class.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -24,7 +24,7 @@
# i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
# brain damage and presumably various other packaging systems too
-$VERSION = '0.08104';
+$VERSION = '0.08106';
$VERSION = eval $VERSION; # numify for warning-free dev releases
Modified: DBIx-Class/0.08/branches/on_connect_call/t/36datetime.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/36datetime.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/36datetime.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -5,9 +5,8 @@
use lib qw(t/lib);
use DBICTest;
-eval { require DateTime::Format::MySQL };
-
-plan $@ ? ( skip_all => 'Requires DateTime::Format::MySQL' )
+eval { require DateTime::Format::SQLite };
+plan $@ ? ( skip_all => 'Requires DateTime::Format::SQLite' )
: ( tests => 3 );
my $schema = DBICTest->init_schema(
@@ -24,8 +23,6 @@
my $parser = $schema->storage->datetime_parser();
-# We're currently expecting a MySQL parser. May change in future.
-is($parser, 'DateTime::Format::MySQL', 'Got expected datetime_parser');
-
+is($parser, 'DateTime::Format::SQLite', 'Got expected storage-set datetime_parser');
isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::SQLite', 'storage');
Modified: DBIx-Class/0.08/branches/on_connect_call/t/60core.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/60core.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/60core.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -11,7 +11,7 @@
plan tests => 106;
-eval { require DateTime::Format::MySQL };
+eval { require DateTime::Format::SQLite };
my $NO_DTFM = $@ ? 1 : 0;
my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'});
@@ -195,7 +195,7 @@
# get_inflated_columns w/relation and accessor alias
SKIP: {
- skip "This test requires DateTime::Format::MySQL", 8 if $NO_DTFM;
+ skip "This test requires DateTime::Format::SQLite", 8 if $NO_DTFM;
isa_ok($new->updated_date, 'DateTime', 'have inflated object via accessor');
my %tdata = $new->get_inflated_columns;
@@ -389,7 +389,7 @@
# test get_inflated_columns with objects
SKIP: {
- skip "This test requires DateTime::Format::MySQL", 5 if $NO_DTFM;
+ skip "This test requires DateTime::Format::SQLite", 5 if $NO_DTFM;
my $event = $schema->resultset('Event')->search->first;
my %edata = $event->get_inflated_columns;
is($edata{'id'}, $event->id, 'got id');
Deleted: DBIx-Class/0.08/branches/on_connect_call/t/68inflate.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/68inflate.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/68inflate.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,112 +0,0 @@
-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 $@;
-
-plan tests => 21;
-
-$schema->class('CD')
-#DBICTest::Schema::CD
-->inflate_column( 'year',
- { inflate => sub { DateTime->new( year => shift ) },
- deflate => sub { shift->year } }
-);
-Class::C3->reinitialize;
-
-# inflation test
-my $cd = $schema->resultset("CD")->find(3);
-
-is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
-
-is( $cd->year->year, 1997, 'inflated year ok' );
-
-is( $cd->year->month, 1, 'inflated month ok' );
-
-eval { $cd->year(\'year +1'); };
-ok(!$@, 'updated year using a scalarref');
-$cd->update();
-$cd->discard_changes();
-
-is( ref($cd->year), 'DateTime', 'year is still a DateTime, ok' );
-
-is( $cd->year->year, 1998, 'updated year, bypassing inflation' );
-
-is( $cd->year->month, 1, 'month is still 1' );
-
-# get_inflated_column test
-
-is( ref($cd->get_inflated_column('year')), 'DateTime', 'get_inflated_column produces a DateTime');
-
-# deflate test
-my $now = DateTime->now;
-$cd->year( $now );
-$cd->update;
-
-$cd = $schema->resultset("CD")->find(3);
-is( $cd->year->year, $now->year, 'deflate ok' );
-
-# set_inflated_column test
-eval { $cd->set_inflated_column('year', $now) };
-ok(!$@, 'set_inflated_column with DateTime object');
-$cd->update;
-
-$cd = $schema->resultset("CD")->find(3);
-is( $cd->year->year, $now->year, 'deflate ok' );
-
-$cd = $schema->resultset("CD")->find(3);
-my $before_year = $cd->year->year;
-eval { $cd->set_inflated_column('year', \'year + 1') };
-ok(!$@, 'set_inflated_column to "year + 1"');
-$cd->update;
-
-$cd = $schema->resultset("CD")->find(3);
-is( $cd->year->year, $before_year+1, 'deflate ok' );
-
-# store_inflated_column test
-$cd = $schema->resultset("CD")->find(3);
-eval { $cd->store_inflated_column('year', $now) };
-ok(!$@, 'store_inflated_column with DateTime object');
-$cd->update;
-
-is( $cd->year->year, $now->year, 'deflate ok' );
-
-# update tests
-$cd = $schema->resultset("CD")->find(3);
-eval { $cd->update({'year' => $now}) };
-ok(!$@, 'update using DateTime object ok');
-is($cd->year->year, $now->year, 'deflate ok');
-
-$cd = $schema->resultset("CD")->find(3);
-$before_year = $cd->year->year;
-eval { $cd->update({'year' => \'year + 1'}) };
-ok(!$@, 'update using scalarref ok');
-
-$cd = $schema->resultset("CD")->find(3);
-is($cd->year->year, $before_year + 1, 'deflate ok');
-
-# discard_changes test
-$cd = $schema->resultset("CD")->find(3);
-# inflate the year
-$before_year = $cd->year->year;
-$cd->update({ year => \'year + 1'});
-$cd->discard_changes;
-
-is($cd->year->year, $before_year + 1, 'discard_changes clears the inflated value');
-
-my $copy = $cd->copy({ year => $now, title => "zemoose" });
-
-isnt( $copy->year->year, $before_year, "copy" );
-
-# eval { $cd->store_inflated_column('year', \'year + 1') };
-# print STDERR "ERROR: $@" if($@);
-# ok(!$@, 'store_inflated_column to "year + 1"');
-
-# is_deeply( $cd->year, \'year + 1', 'deflate ok' );
-
Deleted: DBIx-Class/0.08/branches/on_connect_call/t/68inflate_resultclass_hashrefinflator.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/68inflate_resultclass_hashrefinflator.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/68inflate_resultclass_hashrefinflator.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,126 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More qw(no_plan);
-use lib qw(t/lib);
-use DBICTest;
-my $schema = DBICTest->init_schema();
-
-
-# Under some versions of SQLite if the $rs is left hanging around it will lock
-# So we create a scope here cos I'm lazy
-{
- my $rs = $schema->resultset('CD');
-
- # get the defined columns
- my @dbic_cols = sort $rs->result_source->columns;
-
- # use the hashref inflator class as result class
- $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
-
- # fetch first record
- my $datahashref1 = $rs->first;
-
- my @hashref_cols = sort keys %$datahashref1;
-
- is_deeply( \@dbic_cols, \@hashref_cols, 'returned columns' );
-}
-
-
-sub check_cols_of {
- my ($dbic_obj, $datahashref) = @_;
-
- foreach my $col (keys %$datahashref) {
- # plain column
- if (not ref ($datahashref->{$col}) ) {
- is ($datahashref->{$col}, $dbic_obj->get_column($col), 'same value');
- }
- # related table entry (belongs_to)
- elsif (ref ($datahashref->{$col}) eq 'HASH') {
- check_cols_of($dbic_obj->$col, $datahashref->{$col});
- }
- # multiple related entries (has_many)
- elsif (ref ($datahashref->{$col}) eq 'ARRAY') {
- my @dbic_reltable = $dbic_obj->$col;
- my @hashref_reltable = @{$datahashref->{$col}};
-
- is (scalar @hashref_reltable, scalar @dbic_reltable, 'number of related entries');
-
- # for my $index (0..scalar @hashref_reltable) {
- for my $index (0..scalar @dbic_reltable) {
- my $dbic_reltable_obj = $dbic_reltable[$index];
- my $hashref_reltable_entry = $hashref_reltable[$index];
-
- check_cols_of($dbic_reltable_obj, $hashref_reltable_entry);
- }
- }
- }
-}
-
-# create a cd without tracks for testing empty has_many relationship
-$schema->resultset('CD')->create({ title => 'Silence is golden', artist => 3, year => 2006 });
-
-# order_by to ensure both resultsets have the rows in the same order
-# also check result_class-as-an-attribute syntax
-my $rs_dbic = $schema->resultset('CD')->search(undef,
- {
- prefetch => [ qw/ artist tracks / ],
- order_by => [ 'me.cdid', 'tracks.position' ],
- }
-);
-my $rs_hashrefinf = $schema->resultset('CD')->search(undef,
- {
- prefetch => [ qw/ artist tracks / ],
- order_by => [ 'me.cdid', 'tracks.position' ],
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
- }
-);
-
-my @dbic = $rs_dbic->all;
-my @hashrefinf = $rs_hashrefinf->all;
-
-for my $index (0 .. $#hashrefinf) {
- my $dbic_obj = $dbic[$index];
- my $datahashref = $hashrefinf[$index];
-
- check_cols_of($dbic_obj, $datahashref);
-}
-
-# sometimes for ultra-mega-speed you want to fetch columns in esoteric ways
-# check the inflator over a non-fetching join
-$rs_dbic = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
- prefetch => { cds => 'tracks' },
- order_by => [qw/cds.cdid tracks.trackid/],
-});
-
-$rs_hashrefinf = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
- join => { cds => 'tracks' },
- select => [qw/name tracks.title tracks.cd /],
- as => [qw/name cds.tracks.title cds.tracks.cd /],
- order_by => [qw/cds.cdid tracks.trackid/],
- result_class => 'DBIx::Class::ResultClass::HashRefInflator',
-});
-
- at dbic = map { $_->tracks->all } ($rs_dbic->first->cds->all);
- at hashrefinf = $rs_hashrefinf->all;
-
-is (scalar @dbic, scalar @hashrefinf, 'Equal number of tracks fetched');
-
-for my $index (0 .. $#hashrefinf) {
- my $track = $dbic[$index];
- my $datahashref = $hashrefinf[$index];
-
- is ($track->cd->artist->name, $datahashref->{name}, 'Brought back correct artist');
- for my $col (keys %{$datahashref->{cds}{tracks}}) {
- is ($track->get_column ($col), $datahashref->{cds}{tracks}{$col}, "Correct track '$col'");
- }
-}
-
-# check for same query as above but using extended columns syntax
-$rs_hashrefinf = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
- join => { cds => 'tracks' },
- columns => {name => 'name', 'cds.tracks.title' => 'tracks.title', 'cds.tracks.cd' => 'tracks.cd'},
- order_by => [qw/cds.cdid tracks.trackid/],
-});
-$rs_hashrefinf->result_class('DBIx::Class::ResultClass::HashRefInflator');
-is_deeply [$rs_hashrefinf->all], \@hashrefinf, 'Check query using extended columns syntax';
Deleted: DBIx-Class/0.08/branches/on_connect_call/t/68inflate_serialize.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/68inflate_serialize.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/68inflate_serialize.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,86 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-
-my $schema = DBICTest->init_schema();
-
-use Data::Dumper;
-
-my @serializers = (
- { module => 'YAML.pm',
- inflater => sub { YAML::Load (shift) },
- deflater => sub { die "Expecting a reference" unless (ref $_[0]); YAML::Dump (shift) },
- },
- { module => 'Storable.pm',
- inflater => sub { Storable::thaw (shift) },
- deflater => sub { die "Expecting a reference" unless (ref $_[0]); Storable::nfreeze (shift) },
- },
-);
-
-
-my $selected;
-foreach my $serializer (@serializers) {
- eval { require $serializer->{module} };
- unless ($@) {
- $selected = $serializer;
- last;
- }
-}
-
-plan (skip_all => "No suitable serializer found") unless $selected;
-
-plan (tests => 8);
-DBICTest::Schema::Serialized->inflate_column( 'serialized',
- { inflate => $selected->{inflater},
- deflate => $selected->{deflater},
- },
-);
-Class::C3->reinitialize;
-
-my $struct_hash = {
- a => 1,
- b => [
- { c => 2 },
- ],
- d => 3,
-};
-
-my $struct_array = [
- 'a',
- {
- b => 1,
- c => 2
- },
- 'd',
-];
-
-my $rs = $schema->resultset('Serialized');
-my $inflated;
-
-#======= testing hashref serialization
-
-my $object = $rs->create( {
- id => 1,
- serialized => '',
-} );
-ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
-ok($inflated = $object->serialized, 'hashref inflation');
-is_deeply($inflated, $struct_hash, 'inflated hash matches original');
-
-$object = $rs->create( {
- id => 2,
- serialized => '',
-} );
-eval { $object->set_inflated_column('serialized', $struct_hash) };
-ok(!$@, 'set_inflated_column to a hashref');
-is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
-
-
-#====== testing arrayref serialization
-
-ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
-ok($inflated = $object->serialized, 'arrayref inflation');
-is_deeply($inflated, $struct_array, 'inflated array matches original');
Modified: DBIx-Class/0.08/branches/on_connect_call/t/74mssql.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/74mssql.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/74mssql.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,6 +1,13 @@
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 Test::More;
use lib qw(t/lib);
use DBICTest;
Deleted: DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,174 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-
-{
- local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
- DBICTest::Schema->load_classes('EventTZDeprecated');
- DBICTest::Schema->load_classes('EventTZPg');
-}
-
-my $schema = DBICTest->init_schema();
-
-plan tests => 57;
-
-SKIP: {
- eval { require DateTime::Format::MySQL };
- skip "Need DateTime::Format::MySQL for inflation tests", 50 if $@;
-
-
-# inflation test
-my $event = $schema->resultset("Event")->find(1);
-
-isa_ok($event->starts_at, 'DateTime', 'DateTime returned');
-
-# klunky, but makes older Test::More installs happy
-my $starts = $event->starts_at;
-is("$starts", '2006-04-25T22:24:33', 'Correct date/time');
-
-TODO: {
- local $TODO = "We can't do this yet before 0.09" if DBIx::Class->VERSION < 0.09;
-
- ok(my $row =
- $schema->resultset('Event')->search({ starts_at => $starts })->single);
- is(eval { $row->id }, 1, 'DT in search');
-
- ok($row =
- $schema->resultset('Event')->search({ starts_at => { '>=' => $starts } })->single);
- is(eval { $row->id }, 1, 'DT in search with condition');
-}
-
-# create using DateTime
-my $created = $schema->resultset('Event')->create({
- starts_at => DateTime->new(year=>2006, month=>6, day=>18),
- created_on => DateTime->new(year=>2006, month=>6, day=>23)
-});
-my $created_start = $created->starts_at;
-
-isa_ok($created->starts_at, 'DateTime', 'DateTime returned');
-is("$created_start", '2006-06-18T00:00:00', 'Correct date/time');
-
-## timestamp field
-isa_ok($event->created_on, 'DateTime', 'DateTime returned');
-
-## varchar fields
-isa_ok($event->varchar_date, 'DateTime', 'DateTime returned');
-isa_ok($event->varchar_datetime, 'DateTime', 'DateTime returned');
-
-## skip inflation field
-isnt(ref($event->skip_inflation), 'DateTime', 'No DateTime returned for skip inflation column');
-
-# klunky, but makes older Test::More installs happy
-my $createo = $event->created_on;
-is("$createo", '2006-06-22T21:00:05', 'Correct date/time');
-
-my $created_cron = $created->created_on;
-
-isa_ok($created->created_on, 'DateTime', 'DateTime returned');
-is("$created_cron", '2006-06-23T00:00:00', 'Correct date/time');
-
-
-# Test "timezone" parameter
-
-foreach my $tbl (qw/EventTZ EventTZDeprecated/) {
- my $event_tz = $schema->resultset($tbl)->create({
- starts_at => DateTime->new(year=>2007, month=>12, day=>31, time_zone => "America/Chicago" ),
- created_on => DateTime->new(year=>2006, month=>1, day=>31,
- hour => 13, minute => 34, second => 56, time_zone => "America/New_York" ),
- });
-
- is ($event_tz->starts_at->day_name, "Montag", 'Locale de_DE loaded: day_name');
- is ($event_tz->starts_at->month_name, "Dezember", 'Locale de_DE loaded: month_name');
- is ($event_tz->created_on->day_name, "Tuesday", 'Default locale loaded: day_name');
- is ($event_tz->created_on->month_name, "January", 'Default locale loaded: month_name');
-
- my $starts_at = $event_tz->starts_at;
- is("$starts_at", '2007-12-31T00:00:00', 'Correct date/time using timezone');
-
- my $created_on = $event_tz->created_on;
- is("$created_on", '2006-01-31T12:34:56', 'Correct timestamp using timezone');
- is($event_tz->created_on->time_zone->name, "America/Chicago", "Correct timezone");
-
- my $loaded_event = $schema->resultset($tbl)->find( $event_tz->id );
-
- isa_ok($loaded_event->starts_at, 'DateTime', 'DateTime returned');
- $starts_at = $loaded_event->starts_at;
- is("$starts_at", '2007-12-31T00:00:00', 'Loaded correct date/time using timezone');
- is($starts_at->time_zone->name, 'America/Chicago', 'Correct timezone');
-
- isa_ok($loaded_event->created_on, 'DateTime', 'DateTime returned');
- $created_on = $loaded_event->created_on;
- is("$created_on", '2006-01-31T12:34:56', 'Loaded correct timestamp using timezone');
- is($created_on->time_zone->name, 'America/Chicago', 'Correct timezone');
-
- # Test floating timezone warning
- # We expect one warning
- SKIP: {
- skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK};
- local $SIG{__WARN__} = sub {
- like(
- shift,
- qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/,
- 'Floating timezone warning'
- );
- };
- my $event_tz_floating = $schema->resultset($tbl)->create({
- starts_at => DateTime->new(year=>2007, month=>12, day=>31, ),
- created_on => DateTime->new(year=>2006, month=>1, day=>31,
- hour => 13, minute => 34, second => 56, ),
- });
- delete $SIG{__WARN__};
- };
-
- # This should fail to set
- my $prev_str = "$created_on";
- $loaded_event->update({ created_on => '0000-00-00' });
- is("$created_on", $prev_str, "Don't update invalid dates");
-
- my $invalid = $schema->resultset('Event')->create({
- starts_at => '0000-00-00',
- created_on => $created_on
- });
-
- is( $invalid->get_column('starts_at'), '0000-00-00', "Invalid date stored" );
- is( $invalid->starts_at, undef, "Inflate to undef" );
-
- $invalid->created_on('0000-00-00');
- $invalid->update;
-
- {
- local $@;
- eval { $invalid->created_on };
- like( $@, qr/invalid date format/i, "Invalid date format exception");
- }
-}
-
-## varchar field using inflate_date => 1
-my $varchar_date = $event->varchar_date;
-is("$varchar_date", '2006-07-23T00:00:00', 'Correct date/time');
-
-## varchar field using inflate_datetime => 1
-my $varchar_datetime = $event->varchar_datetime;
-is("$varchar_datetime", '2006-05-22T19:05:07', 'Correct date/time');
-
-## skip inflation field
-my $skip_inflation = $event->skip_inflation;
-is ("$skip_inflation", '2006-04-21 18:04:06', 'Correct date/time');
-
-} # Skip if no MySQL DT::Formatter
-
-SKIP: {
- eval { require DateTime::Format::Pg };
- skip ('Need DateTime::Format::Pg for timestamp inflation tests', 3) if $@;
-
- my $event = $schema->resultset("EventTZPg")->find(1);
- $event->update({created_on => '2009-01-15 17:00:00+00'});
- $event->discard_changes;
- isa_ok($event->created_on, "DateTime") or diag $event->created_on;
- is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
- # Time zone difference -> -6hours
- is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
-}
Modified: DBIx-Class/0.08/branches/on_connect_call/t/95sql_maker.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/95sql_maker.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/95sql_maker.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -51,6 +51,7 @@
# Make sure the carp/croak override in SQLA works (via SQLAHacks)
my $file = __FILE__;
+$file = "\Q$file\E";
throws_ok (sub {
$schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query;
}, qr/$file/, 'Exception correctly croak()ed');
Deleted: DBIx-Class/0.08/branches/on_connect_call/t/96file_column.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/96file_column.t 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/96file_column.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -1,85 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use lib qw(t/lib);
-use DBICTest;
-use IO::File;
-use File::Compare;
-use Path::Class qw/file/;
-
-my $schema = DBICTest->init_schema();
-
-plan tests => 10;
-
-my $rs = $schema->resultset('FileColumn');
-my $fname = '96file_column.t';
-my $source_file = file('t', $fname);
-my $fh = $source_file->open('r') or die "failed to open $source_file: $!\n";
-my $fc = eval {
- $rs->create({ file => { handle => $fh, filename => $fname } })
-};
-is ( $@, '', 'created' );
-
-$fh->close;
-
-my $storage = file(
- $fc->column_info('file')->{file_column_path},
- $fc->id,
- $fc->file->{filename},
-);
-ok ( -e $storage, 'storage exists' );
-
-# read it back
-$fc = $rs->find({ id => $fc->id });
-
-is ( $fc->file->{filename}, $fname, 'filename matches' );
-ok ( compare($storage, $source_file) == 0, 'file contents matches' );
-
-# update
-my $new_fname = 'File.pm';
-my $new_source_file = file(qw/lib DBIx Class InflateColumn File.pm/);
-my $new_storage = file(
- $fc->column_info('file')->{file_column_path},
- $fc->id,
- $new_fname,
-);
-$fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n";
-
-$fc->file({ handle => $fh, filename => $new_fname });
-$fc->update;
-
-TODO: {
- local $TODO = 'design change required';
- ok ( ! -e $storage, 'old storage does not exist' );
-};
-
-ok ( -e $new_storage, 'new storage exists' );
-
-# read it back
-$fc = $rs->find({ id => $fc->id });
-
-is ( $fc->file->{filename}, $new_fname, 'new filname matches' );
-ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' );
-
-$fc->delete;
-
-ok ( ! -e $storage, 'storage deleted' );
-
-$fh = $source_file->openr or die "failed to open $source_file: $!\n";
-$fc = $rs->create({ file => { handle => $fh, filename => $fname } });
-
-# read it back
-$fc->discard_changes;
-
-$storage = file(
- $fc->column_info('file')->{file_column_path},
- $fc->id,
- $fc->file->{filename},
-);
-
-TODO: {
- local $TODO = 'need resultset delete override to delete_all';
- $rs->delete;
- ok ( ! -e $storage, 'storage does not exist after $rs->delete' );
-};
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/core.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/68inflate.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/core.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/core.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,113 @@
+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 $@;
+
+plan tests => 22;
+
+$schema->class('CD') ->inflate_column( 'year',
+ { inflate => sub { DateTime->new( year => shift ) },
+ deflate => sub { shift->year } }
+);
+
+# inflation test
+my $cd = $schema->resultset("CD")->find(3);
+
+is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
+
+is( $cd->year->year, 1997, 'inflated year ok' );
+
+is( $cd->year->month, 1, 'inflated month ok' );
+
+eval { $cd->year(\'year +1'); };
+ok(!$@, 'updated year using a scalarref');
+$cd->update();
+$cd->discard_changes();
+
+is( ref($cd->year), 'DateTime', 'year is still a DateTime, ok' );
+
+is( $cd->year->year, 1998, 'updated year, bypassing inflation' );
+
+is( $cd->year->month, 1, 'month is still 1' );
+
+# get_inflated_column test
+
+is( ref($cd->get_inflated_column('year')), 'DateTime', 'get_inflated_column produces a DateTime');
+
+# deflate test
+my $now = DateTime->now;
+$cd->year( $now );
+$cd->update;
+
+$cd = $schema->resultset("CD")->find(3);
+is( $cd->year->year, $now->year, 'deflate ok' );
+
+# set_inflated_column test
+eval { $cd->set_inflated_column('year', $now) };
+ok(!$@, 'set_inflated_column with DateTime object');
+$cd->update;
+
+$cd = $schema->resultset("CD")->find(3);
+is( $cd->year->year, $now->year, 'deflate ok' );
+
+$cd = $schema->resultset("CD")->find(3);
+my $before_year = $cd->year->year;
+eval { $cd->set_inflated_column('year', \'year + 1') };
+ok(!$@, 'set_inflated_column to "year + 1"');
+$cd->update;
+
+TODO: {
+ local $TODO = 'this was left in without a TODO - should it work?';
+
+ eval {
+ $cd->store_inflated_column('year', \'year + 1');
+ is_deeply( $cd->year, \'year + 1', 'deflate ok' );
+ };
+ ok(!$@, 'store_inflated_column to "year + 1"');
+}
+
+$cd = $schema->resultset("CD")->find(3);
+is( $cd->year->year, $before_year+1, 'deflate ok' );
+
+# store_inflated_column test
+$cd = $schema->resultset("CD")->find(3);
+eval { $cd->store_inflated_column('year', $now) };
+ok(!$@, 'store_inflated_column with DateTime object');
+$cd->update;
+
+is( $cd->year->year, $now->year, 'deflate ok' );
+
+# update tests
+$cd = $schema->resultset("CD")->find(3);
+eval { $cd->update({'year' => $now}) };
+ok(!$@, 'update using DateTime object ok');
+is($cd->year->year, $now->year, 'deflate ok');
+
+$cd = $schema->resultset("CD")->find(3);
+$before_year = $cd->year->year;
+eval { $cd->update({'year' => \'year + 1'}) };
+ok(!$@, 'update using scalarref ok');
+
+$cd = $schema->resultset("CD")->find(3);
+is($cd->year->year, $before_year + 1, 'deflate ok');
+
+# discard_changes test
+$cd = $schema->resultset("CD")->find(3);
+# inflate the year
+$before_year = $cd->year->year;
+$cd->update({ year => \'year + 1'});
+$cd->discard_changes;
+
+is($cd->year->year, $before_year + 1, 'discard_changes clears the inflated value');
+
+my $copy = $cd->copy({ year => $now, title => "zemoose" });
+
+isnt( $copy->year->year, $before_year, "copy" );
+
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,76 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+eval { require DateTime::Format::SQLite };
+plan $@
+ ? ( skip_all => "Need DateTime::Format::SQLite for DT inflation tests" )
+ : ( tests => 18 )
+;
+
+# inflation test
+my $event = $schema->resultset("Event")->find(1);
+
+isa_ok($event->starts_at, 'DateTime', 'DateTime returned');
+
+# klunky, but makes older Test::More installs happy
+my $starts = $event->starts_at;
+is("$starts", '2006-04-25T22:24:33', 'Correct date/time');
+
+TODO: {
+ local $TODO = "We can't do this yet before 0.09" if DBIx::Class->VERSION < 0.09;
+
+ ok(my $row =
+ $schema->resultset('Event')->search({ starts_at => $starts })->single);
+ is(eval { $row->id }, 1, 'DT in search');
+
+ ok($row =
+ $schema->resultset('Event')->search({ starts_at => { '>=' => $starts } })->single);
+ is(eval { $row->id }, 1, 'DT in search with condition');
+}
+
+# create using DateTime
+my $created = $schema->resultset('Event')->create({
+ starts_at => DateTime->new(year=>2006, month=>6, day=>18),
+ created_on => DateTime->new(year=>2006, month=>6, day=>23)
+});
+my $created_start = $created->starts_at;
+
+isa_ok($created->starts_at, 'DateTime', 'DateTime returned');
+is("$created_start", '2006-06-18T00:00:00', 'Correct date/time');
+
+## timestamp field
+isa_ok($event->created_on, 'DateTime', 'DateTime returned');
+
+## varchar fields
+isa_ok($event->varchar_date, 'DateTime', 'DateTime returned');
+isa_ok($event->varchar_datetime, 'DateTime', 'DateTime returned');
+
+## skip inflation field
+isnt(ref($event->skip_inflation), 'DateTime', 'No DateTime returned for skip inflation column');
+
+# klunky, but makes older Test::More installs happy
+my $createo = $event->created_on;
+is("$createo", '2006-06-22T21:00:05', 'Correct date/time');
+
+my $created_cron = $created->created_on;
+
+isa_ok($created->created_on, 'DateTime', 'DateTime returned');
+is("$created_cron", '2006-06-23T00:00:00', 'Correct date/time');
+
+## varchar field using inflate_date => 1
+my $varchar_date = $event->varchar_date;
+is("$varchar_date", '2006-07-23T00:00:00', 'Correct date/time');
+
+## varchar field using inflate_datetime => 1
+my $varchar_datetime = $event->varchar_datetime;
+is("$varchar_datetime", '2006-05-22T19:05:07', 'Correct date/time');
+
+## skip inflation field
+my $skip_inflation = $event->skip_inflation;
+is ("$skip_inflation", '2006-04-21 18:04:06', 'Correct date/time');
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_mysql.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_mysql.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_mysql.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,97 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+use DBICTest::Schema;
+
+{
+ local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
+ DBICTest::Schema->load_classes('EventTZ');
+ DBICTest::Schema->load_classes('EventTZDeprecated');
+}
+
+eval { require DateTime::Format::MySQL };
+plan $@
+ ? ( skip_all => "Need DateTime::Format::MySQL for inflation tests")
+ : ( tests => 33 )
+;
+
+my $schema = DBICTest->init_schema();
+
+# Test "timezone" parameter
+foreach my $tbl (qw/EventTZ EventTZDeprecated/) {
+ my $event_tz = $schema->resultset($tbl)->create({
+ starts_at => DateTime->new(year=>2007, month=>12, day=>31, time_zone => "America/Chicago" ),
+ created_on => DateTime->new(year=>2006, month=>1, day=>31,
+ hour => 13, minute => 34, second => 56, time_zone => "America/New_York" ),
+ });
+
+ is ($event_tz->starts_at->day_name, "Montag", 'Locale de_DE loaded: day_name');
+ is ($event_tz->starts_at->month_name, "Dezember", 'Locale de_DE loaded: month_name');
+ is ($event_tz->created_on->day_name, "Tuesday", 'Default locale loaded: day_name');
+ is ($event_tz->created_on->month_name, "January", 'Default locale loaded: month_name');
+
+ my $starts_at = $event_tz->starts_at;
+ is("$starts_at", '2007-12-31T00:00:00', 'Correct date/time using timezone');
+
+ my $created_on = $event_tz->created_on;
+ is("$created_on", '2006-01-31T12:34:56', 'Correct timestamp using timezone');
+ is($event_tz->created_on->time_zone->name, "America/Chicago", "Correct timezone");
+
+ my $loaded_event = $schema->resultset($tbl)->find( $event_tz->id );
+
+ isa_ok($loaded_event->starts_at, 'DateTime', 'DateTime returned');
+ $starts_at = $loaded_event->starts_at;
+ is("$starts_at", '2007-12-31T00:00:00', 'Loaded correct date/time using timezone');
+ is($starts_at->time_zone->name, 'America/Chicago', 'Correct timezone');
+
+ isa_ok($loaded_event->created_on, 'DateTime', 'DateTime returned');
+ $created_on = $loaded_event->created_on;
+ is("$created_on", '2006-01-31T12:34:56', 'Loaded correct timestamp using timezone');
+ is($created_on->time_zone->name, 'America/Chicago', 'Correct timezone');
+
+ # Test floating timezone warning
+ # We expect one warning
+ SKIP: {
+ skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK};
+ local $SIG{__WARN__} = sub {
+ like(
+ shift,
+ qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/,
+ 'Floating timezone warning'
+ );
+ };
+ my $event_tz_floating = $schema->resultset($tbl)->create({
+ starts_at => DateTime->new(year=>2007, month=>12, day=>31, ),
+ created_on => DateTime->new(year=>2006, month=>1, day=>31,
+ hour => 13, minute => 34, second => 56, ),
+ });
+ delete $SIG{__WARN__};
+ };
+
+ # This should fail to set
+ my $prev_str = "$created_on";
+ $loaded_event->update({ created_on => '0000-00-00' });
+ is("$created_on", $prev_str, "Don't update invalid dates");
+}
+
+# Test invalid DT
+my $invalid = $schema->resultset('EventTZ')->create({
+ starts_at => '0000-00-00',
+ created_on => DateTime->now,
+});
+
+is( $invalid->get_column('starts_at'), '0000-00-00', "Invalid date stored" );
+is( $invalid->starts_at, undef, "Inflate to undef" );
+
+$invalid->created_on('0000-00-00');
+$invalid->update;
+
+throws_ok (
+ sub { $invalid->created_on },
+ qr/invalid date format/i,
+ "Invalid date format exception"
+);
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_pg.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/89inflate_datetime.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_pg.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/datetime_pg.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+{
+ local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
+ DBICTest::Schema->load_classes('EventTZPg');
+}
+
+eval { require DateTime::Format::Pg };
+plan $@
+ ? ( skip_all => 'Need DateTime::Format::Pg for timestamp inflation tests')
+ : ( tests => 3 )
+;
+
+
+my $schema = DBICTest->init_schema();
+
+{
+ my $event = $schema->resultset("EventTZPg")->find(1);
+ $event->update({created_on => '2009-01-15 17:00:00+00'});
+ $event->discard_changes;
+ isa_ok($event->created_on, "DateTime") or diag $event->created_on;
+ is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
+ # Time zone difference -> -6hours
+ is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
+}
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/file_column.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/96file_column.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/file_column.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/file_column.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,85 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+use IO::File;
+use File::Compare;
+use Path::Class qw/file/;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 10;
+
+my $rs = $schema->resultset('FileColumn');
+my $source_file = file(__FILE__);
+my $fname = $source_file->basename;
+my $fh = $source_file->open('r') or die "failed to open $source_file: $!\n";
+my $fc = eval {
+ $rs->create({ file => { handle => $fh, filename => $fname } })
+};
+is ( $@, '', 'created' );
+
+$fh->close;
+
+my $storage = file(
+ $fc->column_info('file')->{file_column_path},
+ $fc->id,
+ $fc->file->{filename},
+);
+ok ( -e $storage, 'storage exists' );
+
+# read it back
+$fc = $rs->find({ id => $fc->id });
+
+is ( $fc->file->{filename}, $fname, 'filename matches' );
+ok ( compare($storage, $source_file) == 0, 'file contents matches' );
+
+# update
+my $new_fname = 'File.pm';
+my $new_source_file = file(qw/lib DBIx Class InflateColumn File.pm/);
+my $new_storage = file(
+ $fc->column_info('file')->{file_column_path},
+ $fc->id,
+ $new_fname,
+);
+$fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n";
+
+$fc->file({ handle => $fh, filename => $new_fname });
+$fc->update;
+
+TODO: {
+ local $TODO = 'design change required';
+ ok ( ! -e $storage, 'old storage does not exist' );
+};
+
+ok ( -e $new_storage, 'new storage exists' );
+
+# read it back
+$fc = $rs->find({ id => $fc->id });
+
+is ( $fc->file->{filename}, $new_fname, 'new filname matches' );
+ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' );
+
+$fc->delete;
+
+ok ( ! -e $storage, 'storage deleted' );
+
+$fh = $source_file->openr or die "failed to open $source_file: $!\n";
+$fc = $rs->create({ file => { handle => $fh, filename => $fname } });
+
+# read it back
+$fc->discard_changes;
+
+$storage = file(
+ $fc->column_info('file')->{file_column_path},
+ $fc->id,
+ $fc->file->{filename},
+);
+
+TODO: {
+ local $TODO = 'need resultset delete override to delete_all';
+ $rs->delete;
+ ok ( ! -e $storage, 'storage does not exist after $rs->delete' );
+};
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/hri.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/68inflate_resultclass_hashrefinflator.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/hri.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/hri.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,126 @@
+use strict;
+use warnings;
+
+use Test::More qw(no_plan);
+use lib qw(t/lib);
+use DBICTest;
+my $schema = DBICTest->init_schema();
+
+
+# Under some versions of SQLite if the $rs is left hanging around it will lock
+# So we create a scope here cos I'm lazy
+{
+ my $rs = $schema->resultset('CD');
+
+ # get the defined columns
+ my @dbic_cols = sort $rs->result_source->columns;
+
+ # use the hashref inflator class as result class
+ $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+
+ # fetch first record
+ my $datahashref1 = $rs->first;
+
+ my @hashref_cols = sort keys %$datahashref1;
+
+ is_deeply( \@dbic_cols, \@hashref_cols, 'returned columns' );
+}
+
+
+sub check_cols_of {
+ my ($dbic_obj, $datahashref) = @_;
+
+ foreach my $col (keys %$datahashref) {
+ # plain column
+ if (not ref ($datahashref->{$col}) ) {
+ is ($datahashref->{$col}, $dbic_obj->get_column($col), 'same value');
+ }
+ # related table entry (belongs_to)
+ elsif (ref ($datahashref->{$col}) eq 'HASH') {
+ check_cols_of($dbic_obj->$col, $datahashref->{$col});
+ }
+ # multiple related entries (has_many)
+ elsif (ref ($datahashref->{$col}) eq 'ARRAY') {
+ my @dbic_reltable = $dbic_obj->$col;
+ my @hashref_reltable = @{$datahashref->{$col}};
+
+ is (scalar @hashref_reltable, scalar @dbic_reltable, 'number of related entries');
+
+ # for my $index (0..scalar @hashref_reltable) {
+ for my $index (0..scalar @dbic_reltable) {
+ my $dbic_reltable_obj = $dbic_reltable[$index];
+ my $hashref_reltable_entry = $hashref_reltable[$index];
+
+ check_cols_of($dbic_reltable_obj, $hashref_reltable_entry);
+ }
+ }
+ }
+}
+
+# create a cd without tracks for testing empty has_many relationship
+$schema->resultset('CD')->create({ title => 'Silence is golden', artist => 3, year => 2006 });
+
+# order_by to ensure both resultsets have the rows in the same order
+# also check result_class-as-an-attribute syntax
+my $rs_dbic = $schema->resultset('CD')->search(undef,
+ {
+ prefetch => [ qw/ artist tracks / ],
+ order_by => [ 'me.cdid', 'tracks.position' ],
+ }
+);
+my $rs_hashrefinf = $schema->resultset('CD')->search(undef,
+ {
+ prefetch => [ qw/ artist tracks / ],
+ order_by => [ 'me.cdid', 'tracks.position' ],
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ }
+);
+
+my @dbic = $rs_dbic->all;
+my @hashrefinf = $rs_hashrefinf->all;
+
+for my $index (0 .. $#hashrefinf) {
+ my $dbic_obj = $dbic[$index];
+ my $datahashref = $hashrefinf[$index];
+
+ check_cols_of($dbic_obj, $datahashref);
+}
+
+# sometimes for ultra-mega-speed you want to fetch columns in esoteric ways
+# check the inflator over a non-fetching join
+$rs_dbic = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
+ prefetch => { cds => 'tracks' },
+ order_by => [qw/cds.cdid tracks.trackid/],
+});
+
+$rs_hashrefinf = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
+ join => { cds => 'tracks' },
+ select => [qw/name tracks.title tracks.cd /],
+ as => [qw/name cds.tracks.title cds.tracks.cd /],
+ order_by => [qw/cds.cdid tracks.trackid/],
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+});
+
+ at dbic = map { $_->tracks->all } ($rs_dbic->first->cds->all);
+ at hashrefinf = $rs_hashrefinf->all;
+
+is (scalar @dbic, scalar @hashrefinf, 'Equal number of tracks fetched');
+
+for my $index (0 .. $#hashrefinf) {
+ my $track = $dbic[$index];
+ my $datahashref = $hashrefinf[$index];
+
+ is ($track->cd->artist->name, $datahashref->{name}, 'Brought back correct artist');
+ for my $col (keys %{$datahashref->{cds}{tracks}}) {
+ is ($track->get_column ($col), $datahashref->{cds}{tracks}{$col}, "Correct track '$col'");
+ }
+}
+
+# check for same query as above but using extended columns syntax
+$rs_hashrefinf = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, {
+ join => { cds => 'tracks' },
+ columns => {name => 'name', 'cds.tracks.title' => 'tracks.title', 'cds.tracks.cd' => 'tracks.cd'},
+ order_by => [qw/cds.cdid tracks.trackid/],
+});
+$rs_hashrefinf->result_class('DBIx::Class::ResultClass::HashRefInflator');
+is_deeply [$rs_hashrefinf->all], \@hashrefinf, 'Check query using extended columns syntax';
Copied: DBIx-Class/0.08/branches/on_connect_call/t/inflate/serialize.t (from rev 6605, DBIx-Class/0.08/branches/on_connect_call/t/68inflate_serialize.t)
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/inflate/serialize.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/inflate/serialize.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,86 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+use Data::Dumper;
+
+my @serializers = (
+ { module => 'YAML.pm',
+ inflater => sub { YAML::Load (shift) },
+ deflater => sub { die "Expecting a reference" unless (ref $_[0]); YAML::Dump (shift) },
+ },
+ { module => 'Storable.pm',
+ inflater => sub { Storable::thaw (shift) },
+ deflater => sub { die "Expecting a reference" unless (ref $_[0]); Storable::nfreeze (shift) },
+ },
+);
+
+
+my $selected;
+foreach my $serializer (@serializers) {
+ eval { require $serializer->{module} };
+ unless ($@) {
+ $selected = $serializer;
+ last;
+ }
+}
+
+plan (skip_all => "No suitable serializer found") unless $selected;
+
+plan (tests => 8);
+DBICTest::Schema::Serialized->inflate_column( 'serialized',
+ { inflate => $selected->{inflater},
+ deflate => $selected->{deflater},
+ },
+);
+Class::C3->reinitialize;
+
+my $struct_hash = {
+ a => 1,
+ b => [
+ { c => 2 },
+ ],
+ d => 3,
+};
+
+my $struct_array = [
+ 'a',
+ {
+ b => 1,
+ c => 2
+ },
+ 'd',
+];
+
+my $rs = $schema->resultset('Serialized');
+my $inflated;
+
+#======= testing hashref serialization
+
+my $object = $rs->create( {
+ id => 1,
+ serialized => '',
+} );
+ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
+ok($inflated = $object->serialized, 'hashref inflation');
+is_deeply($inflated, $struct_hash, 'inflated hash matches original');
+
+$object = $rs->create( {
+ id => 2,
+ serialized => '',
+} );
+eval { $object->set_inflated_column('serialized', $struct_hash) };
+ok(!$@, 'set_inflated_column to a hashref');
+is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
+
+
+#====== testing arrayref serialization
+
+ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
+ok($inflated = $object->serialized, 'arrayref inflation');
+is_deeply($inflated, $struct_array, 'inflated array matches original');
Added: DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICNSTest/Bogus/B.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICNSTest/Bogus/B.pm (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICNSTest/Bogus/B.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,6 @@
+package DBICNSTest::Result::B;
+use base qw/DBIx::Class/;
+__PACKAGE__->load_components(qw/PK::Auto Core/);
+__PACKAGE__->table('b');
+__PACKAGE__->add_columns('b');
+1;
Modified: DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/Event.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/Event.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/Event.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -10,7 +10,7 @@
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
- starts_at => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
+ starts_at => { data_type => 'datetime' },
created_on => { data_type => 'timestamp' },
varchar_date => { data_type => 'varchar', inflate_date => 1, size => 20, is_nullable => 1 },
varchar_datetime => { data_type => 'varchar', inflate_datetime => 1, size => 20, is_nullable => 1 },
Modified: DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZ.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZ.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZ.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -10,10 +10,15 @@
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
- starts_at => { data_type => 'datetime', timezone => "America/Chicago", locale => 'de_DE' },
+ starts_at => { data_type => 'datetime', timezone => "America/Chicago", locale => 'de_DE', datetime_undef_if_invalid => 1 },
created_on => { data_type => 'timestamp', timezone => "America/Chicago", floating_tz_ok => 1 },
);
__PACKAGE__->set_primary_key('id');
+sub _datetime_parser {
+ require DateTime::Format::MySQL;
+ DateTime::Format::MySQL->new();
+}
+
1;
Modified: DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZDeprecated.pm
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZDeprecated.pm 2009-06-12 00:05:30 UTC (rev 6643)
+++ DBIx-Class/0.08/branches/on_connect_call/t/lib/DBICTest/Schema/EventTZDeprecated.pm 2009-06-12 00:06:35 UTC (rev 6644)
@@ -16,4 +16,10 @@
__PACKAGE__->set_primary_key('id');
+sub _datetime_parser {
+ require DateTime::Format::MySQL;
+ DateTime::Format::MySQL->new();
+}
+
+
1;
Added: DBIx-Class/0.08/branches/on_connect_call/t/update/type_aware.t
===================================================================
--- DBIx-Class/0.08/branches/on_connect_call/t/update/type_aware.t (rev 0)
+++ DBIx-Class/0.08/branches/on_connect_call/t/update/type_aware.t 2009-06-12 00:06:35 UTC (rev 6644)
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 4;
+
+my $artist = $schema->resultset ('Artist')->first;
+ok (!$artist->get_dirty_columns, 'Artist is clean' );
+
+$artist->rank (13);
+ok (!$artist->get_dirty_columns, 'Artist is clean after num value update' );
+$artist->discard_changes;
+
+$artist->rank ('13.00');
+ok (!$artist->get_dirty_columns, 'Artist is clean after string value update' );
+$artist->discard_changes;
+
+# override column info
+$artist->result_source->column_info ('rank')->{is_numeric} = 0;
+$artist->rank ('13.00');
+ok ($artist->get_dirty_columns, 'Artist is updated after is_numeric override' );
+$artist->discard_changes;
More information about the Bast-commits
mailing list