From: Peter Rabbitson Date: Sun, 20 Sep 2009 22:58:09 +0000 (+0000) Subject: Part one of the sybase work by Caelum (mostly reviewed) X-Git-Tag: v0.08113~32^2~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d867eedaa703200d7f0bc329836e99b6bd22bc39;p=dbsrgits%2FDBIx-Class.git Part one of the sybase work by Caelum (mostly reviewed) --- diff --git a/Changes b/Changes index a62fe75..53e4cf3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,16 @@ Revision history for DBIx::Class + - Complete Sybase RDBMS support including: + - Support for TEXT/IMAGE columns + - Support for the 'money' datatype + - Transaction savepoints support + - DateTime inflation support + - Support for bind variables when connecting to a newer Sybase with + OpenClient libraries + - Support for connections via FreeTDS with CASTs for bind variables + when needed + - Support for interpolated variables with proper quoting when + connecting to an older Sybase and/or via FreeTDS - Remove the recommends from Makefile.PL, DBIx::Class is not supposed to have optional dependencies. ever. - Mangle the DBIx/Class.pm POD to be more clear about diff --git a/Makefile.PL b/Makefile.PL index 27ce1ef..8c1e88b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -114,6 +114,12 @@ my %force_requires_if_author = ( 'DateTime::Format::Oracle' => '0', ) : () , + + $ENV{DBICTEST_SYBASE_DSN} + ? ( + 'DateTime::Format::Sybase' => 0, + ) : () + , ); #************************************************************************# # Make *ABSOLUTELY SURE* that nothing on the list aboveis a real require,# @@ -135,7 +141,7 @@ resources 'license' => 'http://dev.perl.org/licenses/'; resources 'repository' => 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/'; resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class'; -no_index 'DBIx::Class::Storage::DBI::Sybase::Base'; +no_index 'DBIx::Class::Storage::DBI::Sybase::Common'; no_index 'DBIx::Class::SQLAHacks'; no_index 'DBIx::Class::SQLAHacks::MSSQL'; no_index 'DBIx::Class::Storage::DBI::AmbiguousGlob'; diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 78fd277..6b85685 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2796,7 +2796,10 @@ sub _resolved_attrs { : ( ( delete $attrs->{columns} ) || - $source->columns + $source->storage->_order_select_columns( + $source, + [ $source->columns ], + ) ) ; diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 89cf5a3..3fd4f7c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1993,6 +1993,18 @@ sub _subq_count_select { return @pcols ? \@pcols : [ 1 ]; } +# +# Returns an ordered list of column names before they are used +# in a SELECT statement. By default simply returns the list +# passed in. +# +# This may be overridden in a specific storage when there are +# requirements such as moving BLOB columns to the end of the +# SELECT list. +sub _order_select_columns { + #my ($self, $source, $columns) = @_; + return @{$_[2]}; +} sub source_bind_attributes { my ($self, $source) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/AutoCast.pm b/lib/DBIx/Class/Storage/DBI/AutoCast.pm index 850015b..d854c16 100644 --- a/lib/DBIx/Class/Storage/DBI/AutoCast.pm +++ b/lib/DBIx/Class/Storage/DBI/AutoCast.pm @@ -29,6 +29,10 @@ converted to: CAST(? as $mapped_type) +This option can also be enabled in L as: + + on_connect_call => ['set_auto_cast'] + =cut sub _prep_for_execute { @@ -60,6 +64,26 @@ sub _prep_for_execute { return ($sql, $bind); } +=head2 connect_call_set_auto_cast + +Executes: + + $schema->storage->auto_cast(1); + +on connection. + +Used as: + + on_connect_call => ['set_auto_cast'] + +in L. + +=cut + +sub connect_call_set_auto_cast { + my $self = shift; + $self->auto_cast(1); +} =head1 AUTHOR diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 1589b5f..8de1865 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -325,6 +325,7 @@ has 'write_handler' => ( _count_select _subq_count_select _subq_update_delete + _order_select_columns svp_rollback svp_begin svp_release diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 41b0c81..2e01e8e 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -4,63 +4,780 @@ use strict; use warnings; use base qw/ - DBIx::Class::Storage::DBI::Sybase::Base - DBIx::Class::Storage::DBI::NoBindVars + DBIx::Class::Storage::DBI::Sybase::Common + DBIx::Class::Storage::DBI::AutoCast /; use mro 'c3'; +use Carp::Clan qw/^DBIx::Class/; +use List::Util (); +use Sub::Name (); + +__PACKAGE__->mk_group_accessors('simple' => + qw/_identity _blob_log_on_update _writer_storage _is_writer_storage + _identity_method/ +); + +my @also_proxy_to_writer_storage = qw/ + disconnect _connect_info _sql_maker _sql_maker_opts disable_sth_caching + auto_savepoint unsafe cursor_class debug debugobj schema +/; + +=head1 NAME + +DBIx::Class::Storage::DBI::Sybase - Sybase support for DBIx::Class + +=head1 SYNOPSIS + +This subclass supports L for real Sybase databases. If you are +using an MSSQL database via L, your storage will be reblessed to +L. + +=head1 DESCRIPTION + +If your version of Sybase does not support placeholders, then your storage +will be reblessed to L. You can +also enable that driver explicitly, see the documentation for more details. + +With this driver there is unfortunately no way to get the C +without doing a C, which is the only way to get the C value in this +mode. + +In addition, they are done on a separate connection so that it's possible to +have active cursors when doing an insert. + +When using C transactions are +disabled, as there are no concurrency issues with C will work +for obtainging the last insert id of an C column, instead of having to +do C