Merge 'trunk' into 'storage-interbase'
Rafael Kitover [Sun, 28 Feb 2010 04:49:17 +0000 (04:49 +0000)]
r23422@hlagh (orig r8802):  ribasushi | 2010-02-23 05:19:19 -0500
Looks like the distdir wrapping is finally taken care of
r23425@hlagh (orig r8805):  ribasushi | 2010-02-23 08:03:20 -0500
remove POD
r23426@hlagh (orig r8806):  ribasushi | 2010-02-23 08:03:38 -0500
More index exclusions
r23428@hlagh (orig r8808):  goraxe | 2010-02-23 09:00:38 -0500
remove short options from dbicadmin
r23429@hlagh (orig r8809):  ribasushi | 2010-02-23 09:13:06 -0500
Whitespace
r23433@hlagh (orig r8813):  ribasushi | 2010-02-24 03:28:42 -0500
 r8585@Thesaurus (orig r8572):  faxm0dem | 2010-02-06 23:01:04 +0100
 sqlt::producer::oracle is now able to handle quotes correctly. Now we need to take advantage of that as currently the oracle producer capitalises everything
 r8586@Thesaurus (orig r8573):  faxm0dem | 2010-02-06 23:03:31 +0100
 the way I thought. ribasushi suggested to override deploy(ment_statements)
 r8607@Thesaurus (orig r8594):  faxm0dem | 2010-02-09 21:53:48 +0100
 should work now
 r8714@Thesaurus (orig r8701):  faxm0dem | 2010-02-14 09:49:44 +0100
 oracle_version
 r8747@Thesaurus (orig r8734):  faxm0dem | 2010-02-17 18:54:45 +0100
 still need to uc source_name if quotes off
 r8817@Thesaurus (orig r8804):  rabbit | 2010-02-23 12:03:23 +0100
 Cleanup code (hopefully no functional changes)
 r8820@Thesaurus (orig r8807):  rabbit | 2010-02-23 14:14:19 +0100
 Proper error message
 r8823@Thesaurus (orig r8810):  faxm0dem | 2010-02-23 15:46:11 +0100
 Schema Object Naming Rules :
 [...]
 However, database names, global database names, and database link names are always case insensitive and are stored as uppercase.

 # source: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements008.htm

 r8824@Thesaurus (orig r8811):  rabbit | 2010-02-23 16:09:36 +0100
 Changes and dep-bump

r23435@hlagh (orig r8815):  ribasushi | 2010-02-24 03:32:53 -0500
Changelogging
r23436@hlagh (orig r8816):  ribasushi | 2010-02-24 03:37:13 -0500
Protect dbicadmin from self-injection when not in make
r23437@hlagh (orig r8817):  ribasushi | 2010-02-24 04:00:42 -0500
Release 0.08120
r23439@hlagh (orig r8819):  ribasushi | 2010-02-24 04:02:34 -0500
Bump trunk version
r23440@hlagh (orig r8820):  goraxe | 2010-02-24 08:21:23 -0500
 do not include hidden opts in generated pod
r23441@hlagh (orig r8821):  ribasushi | 2010-02-24 09:50:33 -0500
small tool to query cpan deps
r23442@hlagh (orig r8822):  ribasushi | 2010-02-25 18:22:50 -0500
Typo

Changes
Makefile.PL
lib/DBIx/Class.pm
lib/DBIx/Class/Admin/Usage.pm
lib/DBIx/Class/Optional/Dependencies.pm
lib/DBIx/Class/Storage/DBI.pm
lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
maint/joint_deps.pl [new file with mode: 0755]
script/dbicadmin

diff --git a/Changes b/Changes
index 6907498..345c19b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,13 +1,19 @@
 Revision history for DBIx::Class
 
+0.08120 2010-02-24 08:58:00 (UTC)
         - Make sure possibly overwritten deployment_statements methods in
           schemas get called on $schema->deploy
         - Fix count() with group_by aliased-function resultsets
+        - with_deferred_fk_checks() Oracle support
         - Massive refactor and cleanup of primary key handling
         - Fixed regression losing custom result_class (really this time)
           (RT#54697)
         - Fixed regression in DBIC SQLT::Parser failing with a classname
           (as opposed to a schema object)
+        - Changes to Storage::DBI::Oracle to accomodate changes in latest
+          SQL::Translator (quote handling)
+        - Make sure deployment_statements is per-storage overridable
+        - Fix dbicadmin's (lack of) POD
 
 0.08119 2010-02-15 09:36:00 (UTC)
         - Add $rs->is_ordered to test for existing order_by on a resultset
index fd920f9..d14e185 100644 (file)
@@ -116,9 +116,6 @@ if ($Module::Install::AUTHOR) {
     unlink 'MANIFEST';
   }
 
-  print "Regenerating dbicadmin.pod\n";
-  system('perl script/dbicadmin --pod > lib/dbicadmin.pod');
-
   print "Regenerating Optional/Dependencies.pod\n";
   require DBIx::Class::Optional::Dependencies;
   DBIx::Class::Optional::Dependencies->_gen_pod;
@@ -128,13 +125,38 @@ if ($Module::Install::AUTHOR) {
   #  PodInherit();
 }
 
+tests_recursive (qw|
+    t
+|);
+
 install_script (qw|
     script/dbicadmin
 |);
 
-tests_recursive (qw|
-    t
-|);
+
+### Mangle makefile - read the comments for more info
+#
+postamble <<"EOP";
+
+# This will add an extra dep-spec for the distdir target,
+# which `make` will fold together in a first-come first-serve
+# fashion. What we do here is essentially adding extra
+# commands to execute once the distdir is assembled (via
+# create_distdir), but before control is returned to a higher
+# calling rule.
+distdir : dbicadmin_pod_inject
+
+# The pod self-injection code is in fact a hidden option in
+# dbicadmin itself
+dbicadmin_pod_inject :
+\tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod
+
+# Regenerate manifest before running create_distdir.
+create_distdir : manifest
+
+EOP
+
+
 
 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
 resources 'license'     => 'http://dev.perl.org/licenses/';
@@ -143,8 +165,10 @@ resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/db
 
 # Deprecated/internal modules need no exposure
 no_index directory => $_ for (qw|
+  lib/DBIx/Class/Admin
   lib/DBIx/Class/SQLAHacks
   lib/DBIx/Class/PK/Auto
+  lib/DBIx/Class/CDBICompat
 |);
 no_index package => $_ for (qw/
   DBIx::Class::SQLAHacks DBIx::Class::Storage::DBIHacks
index 276eb94..bc36bbb 100644 (file)
@@ -27,9 +27,9 @@ sub component_base_class { 'DBIx::Class' }
 # 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.08119_1';
+$VERSION = '0.08120_1';
 
-$VERSION = eval $VERSION; # numify for warning-free dev releases
+$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
 
 sub MODIFY_CODE_ATTRIBUTES {
   my ($class,$code,@attrs) = @_;
index 291fd1e..ddd925a 100644 (file)
@@ -22,13 +22,8 @@ sub set_simple {
 }
 
 
-=head2 pod
-
-This returns the usage formated as a pod document
-
-=cut
-
 
+# This returns the usage formated as a pod document
 sub pod {
   my ($self) = @_;
   return join qq{\n}, $self->pod_leader_text, $self->pod_option_text, $self->pod_authorlic_text;
@@ -44,17 +39,13 @@ sub pod_leader_text {
 
 sub pod_authorlic_text {
 
-  return <<'EOA'
-=head1 AUTHORS
-
-See L<DBIx::Class/CONTRIBUTORS>
-
-=head1 LICENSE
-
-You may distribute this code under the same terms as Perl itself
-
-=cut
-EOA
+  return join ("\n\n",
+    '=head1 AUTHORS',
+    'See L<DBIx::Class/CONTRIBUTORS>',
+    '=head1 LICENSE',
+    'You may distribute this code under the same terms as Perl itself',
+    '=cut',
+  );
 }
 
 
@@ -69,6 +60,7 @@ sub pod_option_text {
   foreach my $opt (@options) {
     my $spec = $opt->{spec};
     my $desc = $opt->{desc};
+    next if ($desc eq 'hidden');
     if ($desc eq 'spacer') {
         $string .= "=back\n\n=head2 $spec\n\n=cut\n\n=over\n\n";
         next;
index 182ae60..6bba18b 100644 (file)
@@ -66,7 +66,7 @@ my $reqs = {
 
   deploy => {
     req => {
-      'SQL::Translator'           => '0.11002',
+      'SQL::Translator'           => '0.11005',
     },
     pod => {
       title => 'Storage::DBI::deploy()',
index 4eaefc0..d526399 100644 (file)
@@ -40,6 +40,7 @@ __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks');
 # Each of these methods need _determine_driver called before itself
 # in order to function reliably. This is a purely DRY optimization
 my @rdbms_specific_methods = qw/
+  deployment_statements
   sqlt_type
   build_datetime_parser
   datetime_parser_type
@@ -2552,8 +2553,8 @@ queries.
 This hook is to allow specific L<DBIx::Class::Storage> drivers to change the
 way these aliases are named.
 
-The default behavior is C<"$relname_$join_count" if $join_count > 1>, otherwise
-C<"$relname">.
+The default behavior is C<< "$relname_$join_count" if $join_count > 1 >>,
+otherwise C<"$relname">.
 
 =cut
 
index 448c203..a993977 100644 (file)
@@ -30,6 +30,22 @@ versions before 9.
 use base qw/DBIx::Class::Storage::DBI/;
 use mro 'c3';
 
+sub deployment_statements {
+  my $self = shift;;
+  my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_;
+
+  $sqltargs ||= {};
+  my $quote_char = $self->schema->storage->sql_maker->quote_char;
+  $sqltargs->{quote_table_names} = $quote_char ? 1 : 0;
+  $sqltargs->{quote_field_names} = $quote_char ? 1 : 0;
+
+  my $oracle_version = eval { $self->_get_dbh->get_info(18) };
+
+  $sqltargs->{producer_args}{oracle_version} = $oracle_version;
+
+  $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest);
+}
+
 sub _dbh_last_insert_id {
   my ($self, $dbh, $source, @columns) = @_;
   my @ids = ();
@@ -44,46 +60,42 @@ sub _dbh_last_insert_id {
 sub _dbh_get_autoinc_seq {
   my ($self, $dbh, $source, $col) = @_;
 
-  # look up the correct sequence automatically
-  my $sql = q{
-    SELECT trigger_body FROM ALL_TRIGGERS t
-    WHERE t.table_name = ?
-    AND t.triggering_event = 'INSERT'
-    AND t.status = 'ENABLED'
-  };
-
-  # trigger_body is a LONG
-  local $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
-
-  my $sth;
+  my $sql_maker = $self->sql_maker;
 
   my $source_name;
-  if ( ref $source->name ne 'SCALAR' ) {
-      $source_name = $source->name;
+  if ( ref $source->name eq 'SCALAR' ) {
+    $source_name = ${$source->name};
   }
   else {
-      $source_name = ${$source->name};
+    $source_name = $source->name;
   }
+  $source_name = uc($source_name) unless $sql_maker->quote_char;
+
+  # trigger_body is a LONG
+  local $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
+
+  # disable default bindtype
+  local $sql_maker->{bindtype} = 'normal';
+
+  # look up the correct sequence automatically
+  my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/;
+  my ($sql, @bind) = $sql_maker->select (
+    'ALL_TRIGGERS',
+    ['trigger_body'],
+    {
+      $schema ? (owner => $schema) : (),
+      table_name => $table || $source_name,
+      triggering_event => 'INSERT',
+      status => 'ENABLED',
+     },
+  );
+  my $sth = $dbh->prepare($sql);
+  $sth->execute (@bind);
 
-  # check for fully-qualified name (eg. SCHEMA.TABLENAME)
-  if ( my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/ ) {
-    $sql = q{
-      SELECT trigger_body FROM ALL_TRIGGERS t
-      WHERE t.owner = ? AND t.table_name = ?
-      AND t.triggering_event = 'INSERT'
-      AND t.status = 'ENABLED'
-    };
-    $sth = $dbh->prepare($sql);
-    $sth->execute( uc($schema), uc($table) );
-  }
-  else {
-    $sth = $dbh->prepare($sql);
-    $sth->execute( uc( $source_name ) );
-  }
   while (my ($insert_trigger) = $sth->fetchrow_array) {
-    return uc($1) if $insert_trigger =~ m!(\w+)\.nextval!i; # col name goes here???
+    return $1 if $insert_trigger =~ m!("?\w+"?)\.nextval!i; # col name goes here???
   }
-  $self->throw_exception("Unable to find a sequence INSERT trigger on table '" . $source->name . "'.");
+  $self->throw_exception("Unable to find a sequence INSERT trigger on table '$source_name'.");
 }
 
 sub _sequence_fetch {
@@ -162,7 +174,7 @@ names to uppercase
 sub columns_info_for {
   my ($self, $table) = @_;
 
-  $self->next::method(uc($table));
+  $self->next::method($table);
 }
 
 =head2 datetime_parser_type
diff --git a/maint/joint_deps.pl b/maint/joint_deps.pl
new file mode 100755 (executable)
index 0000000..cfdbede
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use CPANDB;
+use DBIx::Class::Schema::Loader 0.05;
+use Data::Dumper::Concise;
+
+{
+  package CPANDB::Schema;
+  use base qw/DBIx::Class::Schema::Loader/;
+
+  __PACKAGE__->loader_options (
+    naming => 'v5',
+  );
+}
+
+my $s = CPANDB::Schema->connect (sub { CPANDB->dbh } );
+
+# reference names are unstable - just create rels manually
+# is there a saner way to do that?
+my $distclass = $s->class('Distribution');
+$distclass->has_many (
+  'deps',
+  $s->class('Dependency'),
+  'distribution',
+);
+$s->unregister_source ('Distribution');
+$s->register_class ('Distribution', $distclass);
+
+
+# a proof of concept how to find out who uses us *AND* SQLT
+my $us_and_sqlt = $s->resultset('Distribution')->search (
+  {
+    'deps.dependency' => 'DBIx-Class',
+    'deps_2.dependency' => 'SQL-Translator',
+  },
+  {
+    join => [qw/deps deps/],
+    order_by => 'me.author',
+    select => [ 'me.distribution', 'me.author', map { "$_.phase" } (qw/deps deps_2/)],
+    as => [qw/dist_name dist_author req_dbic_at req_sqlt_at/],
+    result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+  },
+);
+
+print Dumper [$us_and_sqlt->all];
index 44eba49..1830cfa 100755 (executable)
@@ -16,7 +16,7 @@ use DBIx::Class::Admin::Descriptive;
 use DBIx::Class::Admin;
 
 my $short_description = "utility for administrating DBIx::Class schemata";
-my $synopsis_text =qq{ 
+my $synopsis_text =q|
   deploy a schema to a database
   %c --schema=MyApp::Schema \
     --connect='["dbi:SQLite:my.db", "", ""]' \
@@ -26,37 +26,36 @@ my $synopsis_text =qq{
   %c --schema=MyApp::Schema --class=Employee \
     --connect='["dbi:SQLite:my.db", "", ""]' \
     --op=update --set='{ "name": "New_Employee" }'
-}
-;
+|;
 
 my ($opts, $usage) = describe_options(
     "%c: %o",
   (
     ['Actions'],
     ["action" => hidden => { one_of => [
-      ['create|c' => 'Create version diffs needs preversion',],
-      ['upgrade|U' => 'Upgrade the database to the current schema '],
-      ['install|I' => 'Install the schema version tables to an existing database',],
-      ['deploy|d' => 'Deploy the schema to the database',],
-      ['select|s'   => 'Select data from the schema', ],
-      ['insert|i'   => 'Insert data into the schema', ],
-      ['update|u'   => 'Update data in the schema', ], 
-      ['delete|D'   => 'Delete data from the schema',],
+      ['create' => 'Create version diffs needs preversion',],
+      ['upgrade' => 'Upgrade the database to the current schema '],
+      ['install' => 'Install the schema version tables to an existing database',],
+      ['deploy' => 'Deploy the schema to the database',],
+      ['select'   => 'Select data from the schema', ],
+      ['insert'   => 'Insert data into the schema', ],
+      ['update'   => 'Update data in the schema', ], 
+      ['delete'   => 'Delete data from the schema',],
       ['op:s' => 'compatiblity option all of the above can be suppied as --op=<action>'],
-      ['help|h' => 'display this help', { implies => { schema_class => '__dummy__' } } ],
+      ['help' => 'display this help', { implies => { schema_class => '__dummy__' } } ],
       ['selfinject-pod' => 'hidden', { implies => { schema_class => '__dummy__' } } ],
     ], required=> 1 }],
     ['Arguments'],
-    ['schema-class|schema|C:s' => 'The class of the schema to load', { required => 1 } ],
-    ['resultset|resultset_class|class|r:s' => 'The resultset to operate on for data manipulation' ],
-    ['config-stanza|S:s' => 'Where in the config to find the connection_info, supply in form MyApp::Model::DB',],
-    ['config|f:s' => 'Supply the config file for parsing by Config::Any', { depends => 'config_stanza'} ],
-    ['connect-info|n:s%' => 'Supply the connect info as additonal options ie -I dsn=<dsn> user=<user> password=<pass> '],
+    ['schema-class:s' => 'The class of the schema to load', { required => 1 } ],
+    ['resultset|resultset-class|class:s' => 'The resultset to operate on for data manipulation' ],
+    ['config-stanza:s' => 'Where in the config to find the connection_info, supply in form MyApp::Model::DB',],
+    ['config:s' => 'Supply the config file for parsing by Config::Any', { depends => 'config_stanza'} ],
+    ['connect-info:s%' => 'Supply the connect info as additonal options ie -I dsn=<dsn> user=<user> password=<pass> '],
     ['connect:s' => 'Supply the connect info as a json string' ],
-    ['sql-dir|q:s' => 'The directory where sql diffs will be created'],
-    ['sql-type|t:s' => 'The RDBMs flavour you wish to use'],
-    ['version|v:i' => 'Supply a version install'],
-    ['preversion|p:s' => 'The previous version to diff against',],
+    ['sql-dir:s' => 'The directory where sql diffs will be created'],
+    ['sql-type:s' => 'The RDBMs flavour you wish to use'],
+    ['version:i' => 'Supply a version install'],
+    ['preversion:s' => 'The previous version to diff against',],
     ['set:s' => 'JSON data used to perform data operations' ],
     ['attrs:s' => 'JSON string to be used for the second argument for search'],
     ['where:s' => 'JSON string to be used for the where clause of search'],
@@ -69,6 +68,10 @@ my ($opts, $usage) = describe_options(
 die "please only use one of --config or --connect-info\n" if ($opts->{config} and $opts->{connect_info});
 
 if($opts->{selfinject_pod}) {
+
+    die "This is an internal method, do not call!!!\n"
+      unless $ENV{MAKELEVEL};
+
     $usage->synopsis($synopsis_text);
     $usage->short_description($short_description);
     exec (