[Bast-commits] r6649 - in DBIx-Class/0.08/branches/mssql_top_fixes:
lib/DBIx/Class/Storage/DBI/ODBC t
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Fri Jun 12 15:13:32 GMT 2009
Author: frew
Date: 2009-06-12 15:13:32 +0000 (Fri, 12 Jun 2009)
New Revision: 6649
Modified:
DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
DBIx-Class/0.08/branches/mssql_top_fixes/t/746mssql.t
Log:
Now I just need to check if the actual values are set...
Modified: DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm 2009-06-12 14:40:31 UTC (rev 6648)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm 2009-06-12 15:13:32 UTC (rev 6649)
@@ -6,7 +6,30 @@
sub insert_bulk {
my ($self, $source, $cols, $data) = @_;
+
+ my $identity_insert = 0;
+
+ COLUMNS:
+ foreach my $col (@{$cols}) {
+ if ($source->column_info($col)->{is_auto_increment}) {
+ $identity_insert = 1;
+ last COLUMNS;
+ }
+ }
+
+ my $table = $source->from;
+ $source->storage->dbh_do(sub {
+ my ($storage, $dbh, @cols) = @_;
+ $dbh->do("SET IDENTITY_INSERT $table ON;");
+ });
+
next::method(@_);
+
+ $source->storage->dbh_do(sub {
+ my ($storage, $dbh, @cols) = @_;
+ $dbh->do("SET IDENTITY_INSERT $table OFF;");
+ });
+
}
sub _prep_for_execute {
Modified: DBIx-Class/0.08/branches/mssql_top_fixes/t/746mssql.t
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/t/746mssql.t 2009-06-12 14:40:31 UTC (rev 6648)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/t/746mssql.t 2009-06-12 15:13:32 UTC (rev 6649)
@@ -93,13 +93,11 @@
[name] VARCHAR(100),
)
-SET IDENTITY_INSERT Owners ON
-
SQL
});
$schema->populate ('Owners', [
- [qw/id [name] /],
+ [qw/id name /],
[qw/1 wiggle/],
[qw/2 woggle/],
[qw/3 boggle/],
@@ -144,15 +142,15 @@
}, {
prefetch => 'books',
distinct => 1,
- order_by => 'name',
- page => 2,
- rows => 5,
+ #order_by => 'name',
+ #page => 2,
+ #rows => 5,
});
my $owners2 = $schema->resultset ('Owners')->search ({ id => { -in => $owners->get_column ('me.id')->as_query }});
for ($owners, $owners2) {
- is ($_->all, 2, 'Prefetched grouped search returns correct number of rows');
- is ($_->count, 2, 'Prefetched grouped search returns correct count');
+ is ($_->all, 8, 'Prefetched grouped search returns correct number of rows');
+ is ($_->count, 8, 'Prefetched grouped search returns correct count');
}
# try a ->belongs_to direction (no select collapse)
@@ -161,9 +159,9 @@
}, {
prefetch => 'owner',
distinct => 1,
- order_by => 'name',
- page => 2,
- rows => 5,
+ #order_by => 'name',
+ #page => 2,
+ #rows => 5,
});
my $books2 = $schema->resultset ('BooksInLibrary')->search ({ id => { -in => $books->get_column ('me.id')->as_query }});
@@ -172,13 +170,6 @@
is ($_->count, 1, 'Prefetched grouped search returns correct count');
}
- #my $result = $schema->resultset('BooksInLibrary')->search(undef, {
- #page => 1,
- #rows => 25,
- #order_by => ['name', 'title'],
- #prefetch => 'owner'
- #})->first;
-
}
# clean up our mess
More information about the Bast-commits
mailing list