From: Thomas Kratz Date: Thu, 18 May 2006 17:51:07 +0000 (+0000) Subject: DBIx-Class-UUIDColumns now has it's own working test suite X-Git-Tag: v0.01001~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=773544fd3440aba91e3a5ea2246e7818b895ce30;p=dbsrgits%2FDBIx-Class-UUIDColumns.git DBIx-Class-UUIDColumns now has it's own working test suite --- diff --git a/Build.PL b/Build.PL index f1d2ad8..07ff45f 100644 --- a/Build.PL +++ b/Build.PL @@ -4,29 +4,23 @@ use Module::Build; my %arguments = ( create_makefile_pl => 'passthrough', license => 'perl', - module_name => 'DBIx::Class', + module_name => 'DBIx::Class::UUIDColumns', requires => { - 'Data::Page' => 2.00, - 'Scalar::Util' => 0, - 'SQL::Abstract' => 1.20, - 'SQL::Abstract::Limit' => 0.101, - 'Class::C3' => 0.11, - 'Storable' => 0, - 'Class::Data::Accessor' => 0.01, - 'Carp::Clan' => 0, - 'DBI' => 1.40, + 'DBIx::Class' => 0.06002, }, build_requires => { 'DBD::SQLite' => 1.11, }, recommends => { 'Data::UUID' => 0, - 'Module::Find' => 0, - 'Class::Inspector' => 0, + 'APR::UUID' => 0, + 'UUID' => 0, + 'Win32::Guidgen' => 0, + 'Win32API::GUID' => 0, }, create_makefile_pl => 'passthrough', create_readme => 1, - test_files => [ glob('t/*.t'), glob('t/*/*.t') ] + test_files => [ glob('t/*.t')] ); Module::Build->new(%arguments)->create_build_script; diff --git a/Changes b/Changes index 54514fb..631dc44 100644 --- a/Changes +++ b/Changes @@ -1,237 +1,4 @@ -Revision history for DBIx::Class +Revision history for DBIx::Class::UUIDColumns -0.06003 - - make find_or_create_related check defined() instead of truth - - don't unnecessarily fetch rels for cascade_update - - don't set_columns explicitly in update_or_create; instead use - update($hashref) so InflateColumn works - - fix for has_many prefetch with 0 related rows - - make limit error if rows => 0 - - added memory cycle tests and a long-needed weaken call - -0.06002 2006-04-20 00:42:41 - - fix set_from_related to accept undef - - fix to Dumper-induced hash iteration bug - - fix to copy() with non-composed resultsource - - fix to ->search without args to clone rs but maintain cache - - grab $self->dbh once per function in Storage::DBI - - nuke ResultSource caching of ->resultset for consistency reasons - - fix for -and conditions when updating or deleting on a ResultSet - -0.06001 2006-04-08 21:48:43 - - minor fix to update in case of undefined rels - - fixes for cascade delete - - substantial improvements and fixes to deploy - - Added fix for quoting with single table - - Substantial fixes and improvements to deploy - - slice now uses search directly - - fixes for update() on resultset - - bugfix to Cursor to avoid error during DESTROY - - transaction DBI operations now in debug trace output - -0.06000 2006-03-25 18:03:46 - - Lots of documentation improvements - - Minor tweak to related_resultset to prevent it storing a searched rs - - Fixup to columns_info_for when database returns type(size) - - Made do_txn respect void context (on the off-chance somebody cares) - - Fix exception text for nonexistent key in ResultSet::find() - -0.05999_04 2006-03-18 19:20:49 - - Fix for delete on full-table resultsets - - Removed caching on count() and added _count for pager() - - ->connection does nothing if ->storage defined and no args - (and hence ->connect acts like ->clone under the same conditions) - - Storage::DBI throws better exception if no connect info - - columns_info_for made more robust / informative - - ithreads compat added, fork compat improved - - weaken result_source in all resultsets - - Make pg seq extractor less sensitive. - -0.05999_03 2006-03-14 01:58:10 - - has_many prefetch fixes - - deploy now adds drop statements before creates - - deploy outputs debugging statements if DBIX_CLASS_STORAGE_DBI_DEBUG - is set - -0.05999_02 2006-03-10 13:31:37 - - remove test dep on YAML - - additional speed tweaks for C3 - - allow scalarefs passed to order_by to go straight through to SQL - - renamed insert_or_update to update_or_insert (with compat alias) - - hidden lots of packages from the PAUSE Indexer - -0.05999_01 2006-03-09 18:31:44 - - renamed cols attribute to columns (cols still supported) - - added has_column_loaded to Row - - Storage::DBI connect_info supports coderef returning dbh as 1st arg - - load_components() doesn't prepend base when comp. prefixed with + - - $schema->deploy - - HAVING support - - prefetch for has_many - - cache attr for resultsets - - PK::Auto::* no longer required since Storage::DBI::* handle auto-inc - - minor tweak to tests for join edge case - - added cascade_copy relationship attribute - (sponsored by Airspace Software, http://www.airspace.co.uk/) - - clean up set_from_related - - made copy() automatically null out auto-inc columns - - added txn_do() method to Schema, which allows a coderef to be - executed atomically - -0.05007 2006-02-24 00:59:00 - - tweak to Componentised for Class::C3 0.11 - - fixes for auto-inc under MSSQL - -0.05006 2006-02-17 15:32:40 - - storage fix for fork() and workaround for Apache::DBI - - made update(\%hash) work on row as well as rs - - another fix for count with scalar group_by - - remove dependency on Module::Find in 40resultsetmanager.t (RT #17598) - -0.05005 2006-02-13 21:24:51 - - remove build dependency on version.pm - -0.05004 2006-02-13 20:59:00 - - allow specification of related columns via cols attr when primary - keys of the related table are not fetched - - fix count for group_by as scalar - - add horrific fix to make Oracle's retarded limit syntax work - - remove Carp require - - changed UUIDColumns to use new UUIDMaker classes for uuid creation - using whatever module may be available - -0.05003 2006-02-08 17:50:20 - - add component_class accessors and use them for *_class - - small fixes to Serialize and ResultSetManager - - rollback on disconnect, and disconnect on DESTROY - -0.05002 2006-02-06 12:12:03 - - Added recommends for Class::Inspector - - Added skip_all to t/40resultsetmanager.t if no Class::Inspector available - -0.05001 2006-02-05 15:28:10 - - debug output now prints NULL for undef params - - multi-step prefetch along the same rel (e.g. for trees) now works - - added multi-join (join => [ 'foo', 'foo' ]), aliases second to foo_2 - - hack PK::Auto::Pg for "table" names referencing a schema - - find() with attributes works - - added experimental Serialize and ResultSetManager components - - added code attribute recording to DBIx::Class - - fix to find() for complex resultsets - - added of $storage->debugcb(sub { ... }) - - added $source->resultset_attributes accessor - - added include_columns rs attr - -0.05000 2006-02-01 16:48:30 - - assorted doc fixes - - remove ObjectCache, not yet working in 0.05 - - let many_to_many rels have attrs - - fix ID method in PK.pm to be saner for new internals - - fix t/30dbicplain.t to use ::Schema instead of - Catalyst::Model::DBIC::Plain - -0.04999_06 2006-01-28 21:20:32 - - fix Storage/DBI (tried to load deprecated ::Exception component) - -0.04999_05 2006-01-28 20:13:52 - - count will now work for grouped resultsets - - added accessor => option to column_info to specify accessor name - - added $schema->populate to load test data (similar to AR fixtures) - - removed cdbi-t dependencies, only run tests if installed - - Removed DBIx::Class::Exception - - unified throw_exception stuff, using Carp::Clan - - report query when sth generation fails. - - multi-step prefetch! - - inheritance fixes - - test tweaks - -0.04999_04 2006-01-24 21:48:21 - - more documentation improvements - - add columns_info_for for vendor-specific column info (Zbigniew Lukasiak) - - add SQL::Translator::Producer for DBIx::Class table classes (Jess Robinson) - - add unique constraint declaration (Daniel Westermann-Clark) - - add new update_or_create method (Daniel Westermann-Clark) - - rename ResultSetInstance class to ResultSetProxy, ResultSourceInstance - to ResultSourceProxy, and TableInstance to ResultSourceProxy::Table - - minor fixes to UUIDColumns - - add debugfh method and ENV magic for tracing SQL (Nigel Metheringham) - -0.04999_03 2006-01-20 06:05:27 - - imported Jess Robinson's SQL::Translator::Parser::DBIx::Class - - lots of internals cleanup to eliminate result_source_instance requirement - - added register_column and register_relationship class APIs - - made Storage::DBI use prepare_cached safely (thanks to Tim Bunce) - - many documentation improvements (thanks guys!) - - added ->connection, ->connect, ->register_source and ->clone schema methods - - Use croak instead of die for user errors. - -0.04999_02 2006-01-14 07:17:35 - - Schema is now self-contained; no requirement for co-operation - - add_relationship, relationships, relationship_info, has_relationship - - relationship handling on ResultSource - - all table handling now in Table.pm / ResultSource.pm - - added GROUP BY and DISTINCT support - - hacked around SQL::Abstract::Limit some more in DBIC::SQL::Abstract - (this may have fixed complex quoting) - - moved inflation to inflate_result in Row.pm - - added $rs->search_related - - split compose_namespace out of compose_connection in Schema - - ResultSet now handles find - - various *_related methods are now ->search_related->* - - added new_result to ResultSet - -0.04999_01 2005-12-27 03:33:42 - - search and related methods moved to ResultSet - - select and as added to ResultSet attrs - - added DBIx::Class::Table and TableInstance for table-per-class - - added DBIx::Class::ResultSetInstance which handles proxying - search etc. as a superclass of DBIx::Class::DB - - assorted test and code cleanup work - -0.04001 2005-12-13 22:00:00 - - Fix so set_inflated_column calls set_column - - Syntax errors in relationship classes are now reported - - Better error detection in set_primary_key and columns methods - - Documentation improvements - - Better transaction support with txn_* methods - - belongs_to now works when $cond is a string - - PK::Auto::Pg updated, only tries primary keys instead of all cols - -0.04 2005-11-26 - - Moved get_simple and set_simple into AccessorGroup - - Made 'new' die if given invalid columns - - Added has_column and column_info to Table.pm - - Refactored away from direct use of _columns and _primaries - - Switched from NEXT to Class::C3 - -0.03004 - - Added an || '' to the CDBICompat stringify to avoid null warnings - - Updated name section for manual pods -0.03003 2005-11-03 17:00:00 - - POD fixes. - - Changed use to require in Relationship/Base to avoid import. - -0.03002 2005-10-20 22:35:00 - - Minor bugfix to new (Row.pm) - - Schema doesn't die if it can't load a class (Schema.pm) - - New UUID columns plugin (UUIDColumns.pm) - - Documentation improvements. - -0.03001 2005-09-23 14:00:00 - - Fixes to relationship helpers - - IMPORTANT: prefetch/schema combination bug fix - -0.03 2005-09-19 19:35:00 - - Paging support - - Join support on search - - Prefetch support on search - -0.02 2005-08-12 18:00:00 - - Test fixes. - - Performance improvements. - - Oracle primary key support. - - MS-SQL primary key support. - - SQL::Abstract::Limit integration for database-agnostic limiting. - -0.01 2005-08-08 17:10:00 - - initial release +0.00001 + - initial release \ No newline at end of file diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..eaa871c --- /dev/null +++ b/MANIFEST @@ -0,0 +1,20 @@ +Build.PL +Changes +lib/DBIx/Class/UUIDColumns.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/APR/UUID.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/Uniqid.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/UUID.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/UUID.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32/Guidgen.pm +lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32API/GUID.pm +MANIFEST This list of files +t/02pod.t +t/03podcoverage.t.disabled +t/04basic.t +t/05uuid.t +t/lib/CustomUUIDMaker.pm +t/lib/UUIDTest.pm +t/lib/UUIDTest/Schema.pm +t/lib/UUIDTest/Schema/Test.pm +t/lib/UUIDTest/Setup.pm diff --git a/TODO b/TODO index d0726b3..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,19 +0,0 @@ - -2006-01-31 by bluefeet - - Create a DBIx::Class::FilterColumn to replace inflate/deflate. This - component would provide a new syntax for filtering column update and - retrieval through a simple syntax. The syntax would be: - __PACKAGE__->add_columns(phone => { set=>sub{ ... }, get=>sub{ ... } }); - We should still support the old inflate/deflate syntax, but this new - way should be recommended. - -2006-02-07 by JR - - Extract DBIC::SQL::Abstract into a separate module for CPAN - - Chop PK::Auto::Foo up to have PK::Auto refer to an appropriate - DBIx::Storage::DBI::Foo, which will be loaded on connect from Driver info? - - Add deploy method to Schema, which will create DB tables from Schema, via - SQLT - -2006-03-18 by bluefeet - - Support table locking. - diff --git a/lib/DBIx/Class/UUIDColumns.pm b/lib/DBIx/Class/UUIDColumns.pm index fdd6adc..7eca6bb 100644 --- a/lib/DBIx/Class/UUIDColumns.pm +++ b/lib/DBIx/Class/UUIDColumns.pm @@ -3,12 +3,19 @@ package DBIx::Class::UUIDColumns; use strict; use warnings; +use vars qw($VERSION); use base qw/DBIx::Class/; __PACKAGE__->mk_classdata( 'uuid_auto_columns' => [] ); __PACKAGE__->mk_classdata( 'uuid_maker' ); __PACKAGE__->uuid_class( __PACKAGE__->_find_uuid_module ); +# 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 + +$VERSION = '0.06002'; + # be compatible with Class::DBI::UUID sub uuid_columns { my $self = shift; @@ -22,11 +29,11 @@ sub uuid_class { my ($self, $class) = @_; if ($class) { - $class = "DBIx::Class::UUIDMaker$class" if $class =~ /^::/; + $class = "DBIx::Class::UUIDColumns::UUIDMaker$class" if $class =~ /^::/; if (!eval "require $class") { $self->throw_exception("$class could not be loaded: $@"); - } elsif (!$class->isa('DBIx::Class::UUIDMaker')) { + } elsif (!$class->isa('DBIx::Class::UUIDColumns::UUIDMaker')) { $self->throw_exception("$class is not a UUIDMaker subclass"); } else { $self->uuid_maker($class->new); @@ -121,7 +128,7 @@ Takes a list of columns to be filled with uuids during insert. Takes the name of a UUIDMaker subclass to be used for uuid value generation. This can be a fully qualified class name, or a shortcut name starting with :: -that matches one of the available DBIx::Class::UUIDMaker subclasses: +that matches one of the available DBIx::Class::UUIDColumns::UUIDMaker subclasses: __PACKAGE__->uuid_class('CustomUUIDGenerator'); # loads CustomeUUIDGenerator @@ -130,7 +137,7 @@ that matches one of the available DBIx::Class::UUIDMaker subclasses: # loads DBIx::Class::UUIDMaker::Data::UUID; Note that C chacks to see that the specified class isa -DBIx::Class::UUIDMaker subbclass and throws and exception if it isn't. +DBIx::Class::UUIDColumns::UUIDMaker subbclass and throws and exception if it isn't. =head2 uuid_maker @@ -140,7 +147,7 @@ Returns the current UUIDMaker instance for the given module. =head1 SEE ALSO -L +L =head1 AUTHORS diff --git a/lib/DBIx/Class/UUIDMaker.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker.pm similarity index 50% rename from lib/DBIx/Class/UUIDMaker.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker.pm index f492801..a9ca80a 100644 --- a/lib/DBIx/Class/UUIDMaker.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker.pm @@ -1,4 +1,4 @@ -package DBIx::Class::UUIDMaker; +package DBIx::Class::UUIDColumns::UUIDMaker; use strict; use warnings; @@ -16,7 +16,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker - UUID wrapper module +DBIx::Class::UUIDColumns::UUIDMaker - UUID wrapper module =head1 SYNOPSIS @@ -31,7 +31,7 @@ DBIx::Class::UUIDMaker - UUID wrapper module =head1 DESCRIPTION -DBIx::Class::UUIDMaker is a base class used by the various uuid generation +DBIx::Class::UUIDColumns::UUIDMaker is a base class used by the various uuid generation subclasses. =head1 METHODS @@ -42,13 +42,13 @@ Returns the new uuid as a string. =head1 SEE ALSO -L, -L, -L, -L, -L, -L, -L +L, +L, +L, +L, +L, +L, +L =head1 AUTHOR diff --git a/lib/DBIx/Class/UUIDMaker/APR/UUID.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/APR/UUID.pm similarity index 66% rename from lib/DBIx/Class/UUIDMaker/APR/UUID.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/APR/UUID.pm index c7a383d..31797dc 100644 --- a/lib/DBIx/Class/UUIDMaker/APR/UUID.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/APR/UUID.pm @@ -1,9 +1,9 @@ -package DBIx::Class::UUIDMaker::APR::UUID; +package DBIx::Class::UUIDColumns::UUIDMaker::APR::UUID; use strict; use warnings; -use base qw/DBIx::Class::UUIDMaker/; +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; use APR::UUID (); sub as_string { @@ -15,7 +15,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::APR::UUID - Create uuids using APR::UUID +DBIx::Class::UUIDColumns::UUIDMaker::APR::UUID - Create uuids using APR::UUID =head1 SYNOPSIS @@ -26,8 +26,8 @@ DBIx::Class::UUIDMaker::APR::UUID - Create uuids using APR::UUID =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses APR::UUID to generate uuid -strings in the following format: +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses APR::UUID to generate +uuid strings in the following format: 098f2470-bae0-11cd-b579-08002b30bfeb diff --git a/lib/DBIx/Class/UUIDMaker/Data/UUID.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/UUID.pm similarity index 67% rename from lib/DBIx/Class/UUIDMaker/Data/UUID.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/UUID.pm index f70680c..c65880a 100644 --- a/lib/DBIx/Class/UUIDMaker/Data/UUID.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/UUID.pm @@ -1,9 +1,9 @@ -package DBIx::Class::UUIDMaker::Data::UUID; +package DBIx::Class::UUIDColumns::UUIDMaker::Data::UUID; use strict; use warnings; -use base qw/DBIx::Class::UUIDMaker/; +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; use Data::UUID (); sub as_string { @@ -15,7 +15,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::Data::UUID - Create uuids using Data::UUID +DBIx::Class::UUIDColumns::UUIDMaker::Data::UUID - Create uuids using Data::UUID =head1 SYNOPSIS @@ -26,8 +26,8 @@ DBIx::Class::UUIDMaker::Data::UUID - Create uuids using Data::UUID =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses Data::UUID to generate uuid -strings in the following format: +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses Data::UUID to generate +uuid strings in the following format: 098f2470-bae0-11cd-b579-08002b30bfeb diff --git a/lib/DBIx/Class/UUIDMaker/Data/Uniqid.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/Uniqid.pm similarity index 64% rename from lib/DBIx/Class/UUIDMaker/Data/Uniqid.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/Uniqid.pm index 36189e1..cf405dc 100644 --- a/lib/DBIx/Class/UUIDMaker/Data/Uniqid.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Data/Uniqid.pm @@ -1,9 +1,9 @@ -package DBIx::Class::UUIDMaker::Data::Uniqid; +package DBIx::Class::UUIDColumns::UUIDMaker::Data::Uniqid; use strict; use warnings; -use base qw/DBIx::Class::UUIDMaker/; +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; use Data::Uniqid (); sub as_string { @@ -15,7 +15,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::Data::Uniqid - Create uuids using Data::Uniqid +DBIx::Class::UUIDColumns::UUIDMaker::Data::Uniqid - Create uuids using Data::Uniqid =head1 SYNOPSIS @@ -26,8 +26,8 @@ DBIx::Class::UUIDMaker::Data::Uniqid - Create uuids using Data::Uniqid =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses Data::Uniqid to generate uuid -strings using Data::Uniqid::luniqid. +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses Data::Uniqid to generate +uuid strings using Data::Uniqid::luniqid. =head1 METHODS diff --git a/lib/DBIx/Class/UUIDMaker/UUID.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/UUID.pm similarity index 74% rename from lib/DBIx/Class/UUIDMaker/UUID.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/UUID.pm index f6fb802..acd22b4 100644 --- a/lib/DBIx/Class/UUIDMaker/UUID.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/UUID.pm @@ -1,9 +1,9 @@ -package DBIx::Class::UUIDMaker::UUID; +package DBIx::Class::UUIDColumns::UUIDMaker::UUID; use strict; use warnings; -use base qw/DBIx::Class::UUIDMaker/; +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; use UUID (); sub as_string { @@ -19,7 +19,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::UUID - Create uuids using UUID +DBIx::Class::UUIDColumns::UUIDMaker::UUID - Create uuids using UUID =head1 SYNOPSIS @@ -30,7 +30,7 @@ DBIx::Class::UUIDMaker::UUID - Create uuids using UUID =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses UUID to generate uuid +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses UUID to generate uuid strings in the following format: 098f2470-bae0-11cd-b579-08002b30bfeb diff --git a/lib/DBIx/Class/UUIDMaker/Win32/Guidgen.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32/Guidgen.pm similarity index 67% rename from lib/DBIx/Class/UUIDMaker/Win32/Guidgen.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32/Guidgen.pm index d9ba0ce..b7cec97 100644 --- a/lib/DBIx/Class/UUIDMaker/Win32/Guidgen.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32/Guidgen.pm @@ -1,9 +1,9 @@ -package DBIx::Class::UUIDMaker::Win32::Guidgen; +package DBIx::Class::UUIDColumns::UUIDMaker::Win32::Guidgen; use strict; use warnings; -use base qw/DBIx::Class::UUIDMaker/; +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; use Win32::Guidgen (); sub as_string { @@ -18,7 +18,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::Win32::Guidgen - Create uuids using Win32::Guidgen +DBIx::Class::UUIDColumns::UUIDMaker::Win32::Guidgen - Create uuids using Win32::Guidgen =head1 SYNOPSIS @@ -29,8 +29,8 @@ DBIx::Class::UUIDMaker::Win32::Guidgen - Create uuids using Win32::Guidgen =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses Win32::Guidgen to generate uuid -strings in the following format: +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses Win32::Guidgen to +generate uuid strings in the following format: 098f2470-bae0-11cd-b579-08002b30bfeb diff --git a/lib/DBIx/Class/UUIDMaker/Win32API/GUID.pm b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32API/GUID.pm similarity index 70% rename from lib/DBIx/Class/UUIDMaker/Win32API/GUID.pm rename to lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32API/GUID.pm index 89df553..c6661cd 100644 --- a/lib/DBIx/Class/UUIDMaker/Win32API/GUID.pm +++ b/lib/DBIx/Class/UUIDColumns/UUIDMaker/Win32API/GUID.pm @@ -1,4 +1,4 @@ -package DBIx::Class::UUIDMaker::Win32API::GUID; +package DBIx::Class::UUIDColumns::UUIDMaker::Win32API::GUID; use strict; use warnings; @@ -15,7 +15,7 @@ __END__ =head1 NAME -DBIx::Class::UUIDMaker::Win32API::GUID - Create uuids using Win32API::GUID +DBIx::Class::UUIDColumns::UUIDMaker::Win32API::GUID - Create uuids using Win32API::GUID =head1 SYNOPSIS @@ -26,8 +26,8 @@ DBIx::Class::UUIDMaker::Win32API::GUID - Create uuids using Win32API::GUID =head1 DESCRIPTION -This DBIx::Class::UUIDMaker subclass uses Win32API::GUID to generate uuid -strings in the following format: +This DBIx::Class::UUIDColumns::UUIDMaker subclass uses Win32API::GUID to +generate uuid strings in the following format: 098f2470-bae0-11cd-b579-08002b30bfeb diff --git a/t/02pod.t b/t/02pod.t new file mode 100644 index 0000000..ddc2905 --- /dev/null +++ b/t/02pod.t @@ -0,0 +1,6 @@ +use Test::More; + +eval "use Test::Pod 1.14"; +plan skip_all => 'Test::Pod 1.14 required' if $@; + +all_pod_files_ok(); diff --git a/t/03podcoverage.t.disabled b/t/03podcoverage.t.disabled new file mode 100644 index 0000000..d91be5e --- /dev/null +++ b/t/03podcoverage.t.disabled @@ -0,0 +1,7 @@ +use Test::More; + +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; +plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; + +all_pod_coverage_ok(); diff --git a/t/04basic.t b/t/04basic.t new file mode 100644 index 0000000..452f33b --- /dev/null +++ b/t/04basic.t @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + eval "use DBD::SQLite"; + plan $@ + ? ( skip_all => 'needs DBD::SQLite for testing' ) + : ( tests => 2 ); +} + +use lib qw(t/lib); + +use_ok('DBIx::Class::UUIDColumns'); +use_ok('DBIx::Class::UUIDColumns::UUIDMaker'); \ No newline at end of file diff --git a/t/05uuid.t b/t/05uuid.t new file mode 100644 index 0000000..54abb6b --- /dev/null +++ b/t/05uuid.t @@ -0,0 +1,37 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + plan eval "require Data::UUID" || + eval "require APR::UUID" || + eval "require UUID" || + eval "require Win32::Guidgen" || + eval "require Win32API::GUID" + ? ( tests => 3 ) + : ( skip_all => 'needs Data::UUID, APR::UUID, UUID, Win32::Guidgen or Win32API::GUID for testing' ); +} + +use lib qw(t/lib); + +use UUIDTest; +use UUIDTest::Setup; + +my $schema = UUIDTest->schema; +my $row; + + +$row = $schema->resultset('Test')->create({ }); +ok UUIDTest::is_uuid( $row->id ), 'got something that loks like a UUID from Auto'; + +UUIDTest::Schema::Test->uuid_class('CustomUUIDMaker'); +Class::C3->reinitialize(); +$row = $schema->resultset('Test')->create({ }); +ok UUIDTest::is_uuid( $row->id ), 'got something that loks like a UUID from CustomUUIDMaker'; + +UUIDTest::Schema::Test->uuid_class('::Data::UUID'); +Class::C3->reinitialize(); +$row = $schema->resultset('Test')->create({ }); +ok UUIDTest::is_uuid( $row->id ), 'got something that loks like a UUID from Data::UUID'; + +1; \ No newline at end of file diff --git a/t/lib/CustomUUIDMaker.pm b/t/lib/CustomUUIDMaker.pm new file mode 100755 index 0000000..8d70b53 --- /dev/null +++ b/t/lib/CustomUUIDMaker.pm @@ -0,0 +1,14 @@ +package CustomUUIDMaker; + +use strict; +use warnings; + +use base qw/DBIx::Class::UUIDColumns::UUIDMaker/; +use Data::UUID (); + +sub as_string { + return Data::UUID->new->to_string(Data::UUID->new->create); +}; + +1; +__END__ \ No newline at end of file diff --git a/t/lib/UUIDTest.pm b/t/lib/UUIDTest.pm new file mode 100755 index 0000000..5d66484 --- /dev/null +++ b/t/lib/UUIDTest.pm @@ -0,0 +1,32 @@ +package # hide from PAUSE + UUIDTest; + +use strict; +use warnings; +use UUIDTest::Schema; + +sub initialise { + + my $db_file = "t/var/UUIDTest.db"; + + unlink($db_file) if -e $db_file; + unlink($db_file . "-journal") if -e $db_file . "-journal"; + mkdir("t/var") unless -d "t/var"; + + my $dsn = "dbi:SQLite:${db_file}"; + + return UUIDTest::Schema->compose_connection('UUIDTest' => $dsn); +} + +sub is_uuid { + my $value = defined $_[0] ? shift : ''; + + return ($value =~ m/ ^[0-9a-f]{8}- + [0-9a-f]{4}- + [0-9a-f]{4}- + [0-9a-f]{4}- + [0-9a-f]{12}$ + /ix); +}; + +1; diff --git a/t/lib/UUIDTest/Schema.pm b/t/lib/UUIDTest/Schema.pm new file mode 100644 index 0000000..ab60c7f --- /dev/null +++ b/t/lib/UUIDTest/Schema.pm @@ -0,0 +1,10 @@ +package # hide from PAUSE + UUIDTest::Schema; + +use base qw/DBIx::Class::Schema/; + +no warnings qw/qw/; + +__PACKAGE__->load_classes(qw/ Test /); + +1; diff --git a/t/lib/UUIDTest/Schema/Test.pm b/t/lib/UUIDTest/Schema/Test.pm new file mode 100644 index 0000000..ab16ca1 --- /dev/null +++ b/t/lib/UUIDTest/Schema/Test.pm @@ -0,0 +1,17 @@ +package # hide from PAUSE + UUIDTest::Schema::Test; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->load_components(qw/UUIDColumns Core/); +__PACKAGE__->table('test'); +__PACKAGE__->add_columns( + 'id' => { + data_type => 'varchar', + size => 36, + }, +); +__PACKAGE__->set_primary_key('id'); +__PACKAGE__->uuid_columns('id'); + +1; diff --git a/t/lib/UUIDTest/Setup.pm b/t/lib/UUIDTest/Setup.pm new file mode 100755 index 0000000..a9efc71 --- /dev/null +++ b/t/lib/UUIDTest/Setup.pm @@ -0,0 +1,15 @@ +use strict; +use warnings; +use UUIDTest; + +my $schema = UUIDTest->initialise; + +$schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]); + +my $dbh = $schema->storage->dbh; + +$schema->deploy; + +$schema->storage->dbh->do("PRAGMA synchronous = OFF"); + +1; diff --git a/t/var/UUIDTest.db b/t/var/UUIDTest.db new file mode 100644 index 0000000..916f8db Binary files /dev/null and b/t/var/UUIDTest.db differ