X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase%2FASE.pm;h=3915eb2e2b13520743299ed1cf78609a44c6102c;hb=47d7b769c034e04989840b1efc2f5991518cff23;hp=a66f190405e8f190a640289e3bbd4c168ef29931;hpb=bfec318fdd1beb78915622f6187afc63275c356e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index a66f190..3915eb2 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -18,7 +18,7 @@ use Try::Tiny; use Context::Preserve 'preserve_context'; use namespace::clean; -__PACKAGE__->sql_limit_dialect ('RowCountOrGenericSubQ'); +__PACKAGE__->sql_limit_dialect ('GenericSubQ'); __PACKAGE__->sql_quote_char ([qw/[ ]/]); __PACKAGE__->datetime_parser_type( 'DBIx::Class::Storage::DBI::Sybase::ASE::DateTime::Format' @@ -123,7 +123,7 @@ sub _init { if ($self->_using_freetds && (my $ver = $self->_using_freetds_version||999) > 0.82) { carp_once( - "Buggy FreeTDS version $ver detected, statement caching will not work and" + "Buggy FreeTDS version $ver detected, statement caching will not work and " . 'will be disabled.' ); $self->disable_sth_caching(1); @@ -254,8 +254,7 @@ sub _is_lob_column { } sub _prep_for_execute { - my $self = shift; - my ($op, $ident) = @_; + my ($self, $op, $ident, $args) = @_; # ### This is commented out because all tests pass. However I am leaving it @@ -263,6 +262,8 @@ sub _prep_for_execute { ### BTW it doesn't currently work exactly - need better sensitivity to # currently set value # + #my ($op, $ident) = @_; + # # inherit these from the parent for the duration of _prep_for_execute # Don't know how to make a localizing loop with if's, otherwise I would #local $self->{_autoinc_supplied_for_op} @@ -272,7 +273,20 @@ sub _prep_for_execute { # = $self->_parent_storage->_perform_autoinc_retrieval #if ($op eq 'insert' or $op eq 'update') and $self->_parent_storage; - my ($sql, $bind) = $self->next::method (@_); + my $limit; # extract and use shortcut on limit without offset + if ($op eq 'select' and ! $args->[4] and $limit = $args->[3]) { + $args = [ @$args ]; + $args->[3] = undef; + } + + my ($sql, $bind) = $self->next::method($op, $ident, $args); + + # $limit is already sanitized by now + $sql = join( "\n", + "SET ROWCOUNT $limit", + $sql, + "SET ROWCOUNT 0", + ) if $limit; if (my $identity_col = $self->_perform_autoinc_retrieval) { $sql .= "\n" . $self->_fetch_identity_sql($ident, $identity_col) @@ -322,11 +336,9 @@ sub _native_data_type { sub _execute { my $self = shift; - my ($op) = @_; - my ($rv, $sth, @bind) = $self->next::method(@_); - $self->_identity( ($sth->fetchall_arrayref)[0][0] ) + $self->_identity( ($sth->fetchall_arrayref)->[0][0] ) if $self->_perform_autoinc_retrieval; return wantarray ? ($rv, $sth, @bind) : $rv; @@ -1021,9 +1033,9 @@ For example, this will not work: $schema->txn_do(sub { my $rs = $schema->resultset('Book'); - while (my $row = $rs->next) { + while (my $result = $rs->next) { $schema->resultset('MetaData')->create({ - book_id => $row->id, + book_id => $result->id, ... }); } @@ -1068,6 +1080,18 @@ for information on changing the setting on the server side. See L to setup date formats for L. +=head1 LIMITED QUERIES + +Because ASE does not have a good way to limit results in SQL that works for all +types of queries, the limit dialect is set to +L. + +Fortunately, ASE and L support cursors properly, so when +L is too slow you can use +the L +L attribute to simulate limited queries by skipping over +records. + =head1 TEXT/IMAGE COLUMNS L compiled with FreeTDS will B allow you to insert or update