swapped ACCEPT_CONTEXT for COMPONENT, also added the on_connect_do and sql_maker...
Brandon L. Black [Sun, 26 Mar 2006 07:09:30 +0000 (07:09 +0000)]
Build.PL
Changes
lib/Catalyst/Model/DBIC/Schema.pm

index f394ddc..b91de6c 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -12,7 +12,7 @@ my %arguments = (
         'Class::Accessor::Fast' => 0.22,
     },
     recommends         => {
-        'DBIx::Class::Schema::Loader' => '0.02003',
+        'DBIx::Class::Schema::Loader' => '0.02007',
     },
     build_requires     => {
         'Test::More'            => 0.32,
diff --git a/Changes b/Changes
index 8d6860c..f297971 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
 Revision history for Perl extension Catalyst::Model::DBIC::Schema
 
+0.11  Not yet released
+        - Removed on_connect_do config setting
+        - Support for on_connect_do and sql_maker options as part
+          of connect_info in the same way DBIx::Class will, with
+          compat for current DBIx::Class
+        - Changed resultset shortcuts to use COMPONENT instead of
+         ACCEPT_CONTEXT, should be more efficient.
+
 0.10  Wed Mar 22 07:06:02 UTC 2006
         - Added on_connect_do config setting
         - Added convenience method for ->schema->storage from paulm
index 16d012a..710388a 100644 (file)
@@ -6,7 +6,7 @@ use NEXT;
 use UNIVERSAL::require;
 use Carp;
 
-our $VERSION = '0.10';
+our $VERSION = '0.11';
 
 __PACKAGE__->mk_classaccessor('composed_schema');
 __PACKAGE__->mk_accessors('schema');
@@ -27,8 +27,15 @@ Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
                              'postgres',
                              '',
                              { AutoCommit => 1 },
+                             { limit_dialect => 'xxx',
+                               quote_char => q{`},
+                               name_sep => q{@},
+                               on_connect_do => [
+                                   'sql statement 1',
+                                   'sql statement 2',
+                               ]
+                             }
                            ],
-        on_connect_do   => [ 'sql statement 1', 'sql statement 2' ],
     );
 
     1;
@@ -93,11 +100,6 @@ This is not required if C<schema_class> already has connection information
 defined in itself (which would be the case for a Schema defined by
 L<DBIx::Class::Schema::Loader>, for instance).
 
-=item on_connect_do
-
-This is an arrayref of sql statements, which are executed on every connect.
-May not be a valid/useful argument with non-DBI-based Storages.
-
 =item storage_type
 
 Allows the use of a different C<storage_type> than what is set in your
@@ -191,13 +193,25 @@ sub new {
     $self->schema->storage_type($self->{storage_type})
         if $self->{storage_type};
     $self->schema->connection(@{$self->{connect_info}});
-    $self->schema->storage->on_connect_do($self->{on_connect_do})
-        if $self->{on_connect_do};
+
+    # This is temporary, until DBIx::Class supports the same syntax and we
+    #  switch our requisite to that version somewhere down the line.
+    my $last_info = $self->{connect_info}->[-1];
+    if(ref $last_info eq 'HASH') {
+        if(my $on_connect_do = $last_info->{on_connect_do}) {
+            $self->schema->storage->on_connect_do($self->{on_connect_do});
+        }
+        foreach my $sql_maker_opt (qw/limit_dialect quote_char name_sep/) {
+            if(my $opt_val = $last_info->{$sql_maker_opt}) {
+                $self->schema->storage->sql_maker->$sql_maker_opt($opt_val);
+            }
+        }
+    }
 
     no strict 'refs';
     foreach my $moniker ($self->schema->sources) {
         my $classname = "${class}::$moniker";
-        *{"${classname}::ACCEPT_CONTEXT"} = sub {
+        *{"${classname}::COMPONENT"} = sub {
             shift;
             shift->model($model_name)->resultset($moniker);
         }