: "${alias}.$_"
)
}
- } ( ref($attrs->{columns}) eq 'ARRAY' ) ? @{ delete $attrs->{columns}} : (delete $attrs->{columns} || $source->columns );
+ } ( ref($attrs->{columns}) eq 'ARRAY' ) ?
+ @{ delete $attrs->{columns}} :
+ (delete $attrs->{columns} ||
+ $source->storage->order_columns_for_select($source) );
}
# add the additional columns on
foreach ( 'include_columns', '+columns' ) {
return;
}
+=head2 order_columns_for_select
+
+Returns an ordered list of column names for use with a C<SELECT> when the column
+list is not explicitly specified.
+By default returns the result of L<DBIx::Class::ResultSource/columns>.
+
+This may be overridden in a specific storage when there are requirements such
+as moving C<BLOB> columns to the end of the list.
+
+=cut
+
+sub order_columns_for_select {
+ my ($self, $source) = @_;
+
+ return $source->columns;
+}
+
sub DESTROY {
my $self = shift;
return if !$self->_dbh;
$type && $type =~ /(?:text|image|lob|bytea|binary)/i;
}
-# Move TEXT/IMAGE column to the end of select list, and make sure there is only
-# one.
+## This will be useful if we ever implement BLOB filehandle inflation and will
+## need to use the API, but for now it isn't.
#
-# work in progress
-#
-# * column indexes need to be fixed if @$select is reordered, not sure if that's
-# possible
-# * needs to handle hashrefs
-# * for some reason tests pass without this, even though documentation says
-# blobs should be at the end of the select list
-# * needs to at least croak for multiple blobs
-#
-#sub _select_args {
-# my ($self, $ident, $select) = splice @_, 0, 3;
-#
-# my ($alias2src, $rs_alias) = $self->_resolve_ident_sources($ident);
-# my $name_sep = $self->_sql_maker_opts->{name_sep} || '.';
+#sub order_columns_for_select {
+# my ($self, $source) = @_;
#
# my (@non_blobs, @blobs);
#
-# for my $col (@$select) {
-# if (ref $col) {
-## XXX should handle hashrefs too
-# push @non_blobs, $col;
-# next;
-# }
-#
-# $col =~ s/^([^\Q${name_sep}\E]*)\Q${name_sep}\E//;
-# my $alias = $1 || $rs_alias;
-# my $rsrc = $alias2src->{$alias};
-# my $datatype = $rsrc && $rsrc->column_info($col)->{data_type};
-#
-# if ($self->_is_lob_type($datatype)) {
+# for my $col ($source->columns) {
+# if ($self->_is_lob_type($source->column_info($col)->{data_type})) {
# push @blobs, $col;
# } else {
# push @non_blobs, $col;
# }
# }
#
-# croak "cannot select more than a one TEXT/IMAGE column"
+# croak "cannot select more than a one TEXT/IMAGE column at a time"
# if @blobs > 1;
#
-# $self->next::method($ident, [@non_blobs, @blobs], @_);
+# return (@non_blobs, @blobs);
#}
# override to handle TEXT/IMAGE
sub _rebless {
my $self = shift;
$self->disable_sth_caching(1);
+
+# LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
+# huge on some versions of SQL server and can cause memory problems, so we
+# fix it up here.
+ my $dbh = $self->_dbh;
+
+ my $text_size = eval { $self->_dbi_connect_info->[-1]->{LongReadLen} } ||
+ 32768; # the DBD::Sybase default
+
+ $dbh->do("set textsize $text_size");
}
1;
my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
-my $TESTS = 31 + 2;
+my $TESTS = 29 + 2;
if (not ($dsn && $user)) {
plan skip_all =>
# mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t
SKIP: {
- skip 'Need at least version 1.09 of DBD::Sybase to test TEXT/IMAGE', 14
+ skip 'Need at least version 1.09 of DBD::Sybase to test TEXT/IMAGE', 12
unless $DBD::Sybase::VERSION >= 1.09;
my $dbh = $schema->storage->dbh;
};
diag $@ if $@;
ok($got eq $binstr{large}, "verified inserted large blob");
-
- # Test select args ordering on a ->find for a table with one blob
- {
- local $SIG{__WARN__} = sub {};
- eval { $dbh->do('DROP TABLE single_blob_test') };
-
- $dbh->do(qq[
- CREATE TABLE single_blob_test
- (
- id INT IDENTITY PRIMARY KEY,
- blob IMAGE NULL,
- foo VARCHAR(256) NULL
- )
- ],{ RaiseError => 1, PrintError => 0 });
- }
- $rs = $schema->resultset('SingleBlob');
- $created = eval { $rs->create({
- blob => $binstr{large}, foo => 'dummy'
- }) };
- ok(!$@, "inserted single large blob without dying");
- diag $@ if $@;
-
- $got = eval { $rs->find($created->id)->blob };
- diag $@ if $@;
- ok($got eq $binstr{large}, "verified inserted large blob through ->find");
}
}
if (my $dbh = eval { $schema->storage->_dbh }) {
$dbh->do('DROP TABLE artist');
eval { $dbh->do('DROP TABLE bindtype_test') };
- eval { $dbh->do('DROP TABLE single_blob_test') };
}
}