From: Rafael Kitover Date: Sat, 27 Mar 2010 22:48:58 +0000 (-0400) Subject: try a couple queries to get MSSQL collation X-Git-Tag: 0.06000~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7a0a0401b8ae46717637cd99a43f24492ce1420;p=dbsrgits%2FDBIx-Class-Schema-Loader.git try a couple queries to get MSSQL collation --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 71d49d4..3790b81 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -42,11 +42,19 @@ sub _setup { my $dbh = $self->schema->storage->dbh; - my ($collation_name) = $dbh->selectrow_array(<<'EOS'); -SELECT collation_name -FROM sys.databases -WHERE name = DB_NAME() -EOS + # We use the sys.databases query for the general case, and fallback to + # databasepropertyex() if for some reason sys.databases is not available, + # which does not work over DBD::ODBC with unixODBC+FreeTDS. + # + # XXX why does databasepropertyex() not work over DBD::ODBC ? + my ($collation_name) = + eval { $dbh->selectrow_array('SELECT collation_name FROM sys.databases WHERE name = DB_NAME()') } + || eval { $dbh->selectrow_array("SELECT databasepropertyex(DB_NAME(), 'collation')") }; + + if (not $collation_name) { + $self->case_sensitive_collation(0); # most likely not + return; + } my ($sensitivity) = $collation_name =~ /(C\w)_[A-z]+\z/;