From: Rafael Kitover Date: Tue, 30 Mar 2010 01:27:47 +0000 (-0400) Subject: doc MSSQL case issues X-Git-Tag: 0.06000~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b065e3dfdba7c7e758e07c062129f317708d32fb;p=dbsrgits%2FDBIx-Class-Schema-Loader.git doc MSSQL case issues --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 29862b6..52f325a 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -27,6 +27,26 @@ L. See L and L for usage information. +=head1 CASE SENSITIVITY + +Most MSSQL databases use C (case-insensitive) collation, for this reason +generated column names are lower-cased as this makes them easier to work with +in L. + +We attempt to detect the database collation at startup, and set the column +lowercasing behavior accordingly, as lower-cased column names do not work on +case-sensitive databases. + +If you are using FreeTDS with C set to C<8.0> the collation +detection may fail, and Loader will default to case-insensitive mode. C C<7.0> will work fine. + +If this happens set: + + case_sensitive_collation => 1 + +in your Loader options to override it. + =cut sub _is_case_sensitive { @@ -40,6 +60,8 @@ sub _setup { $self->next::method; + return if defined $self->case_sensitive_collation; + my $dbh = $self->schema->storage->dbh; # We use the sys.databases query for the general case, and fallback to @@ -54,7 +76,13 @@ sub _setup { || eval { $dbh->selectrow_array("SELECT databasepropertyex(DB_NAME(), 'Collation')") }; if (not $collation_name) { - $self->case_sensitive_collation(0); # most likely not + warn <<'EOF'; + +WARNING: MSSQL Collation detection failed. Defaulting to case-insensitive mode. +Override the 'case_sensitive_collation' attribute in your Loader options if +needed. +EOF + $self->case_sensitive_collation(0); return; }