From: Peter Rabbitson Date: Thu, 4 Jul 2013 15:15:16 +0000 (+0200) Subject: Propagate quote_names setting to SQLite SQLT producer X-Git-Tag: v0.08260~204 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9b5239ac2e308ac231d4a17351e3465a285e7fa;p=dbsrgits%2FDBIx-Class.git Propagate quote_names setting to SQLite SQLT producer --- diff --git a/Changes b/Changes index 771a55e..4ab2210 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class + * Fixes + - Setting quote_names propagates to SQL::Translator when producing + SQLite DDL (it is one of the few producers *NOT* quoting by default) + * Misc - Replace $row with $result in all docs to be consistent and to clarify various return values diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index 82c0f17..bd63417 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -232,6 +232,10 @@ sub deployment_statements { $sqltargs->{producer_args}{sqlite_version} = $dver; } + $sqltargs->{quote_identifiers} + = !!$self->sql_maker->_quote_chars + if ! exists $sqltargs->{quote_identifiers}; + $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); } diff --git a/t/86sqlt.t b/t/86sqlt.t index 89783d3..caea89f 100644 --- a/t/86sqlt.t +++ b/t/86sqlt.t @@ -26,7 +26,7 @@ sub DBICTest::Schema::deployment_statements { # Check deployment statements ctx sensitivity { my $schema = DBICTest->init_schema (no_deploy => 1); - my $not_first_table_creation_re = qr/CREATE TABLE fourkeys_to_twokeys/; + my $not_first_table_creation_re = qr/CREATE TABLE "fourkeys_to_twokeys"/; my $statements = $schema->deployment_statements; like ( diff --git a/t/storage/quote_names.t b/t/storage/quote_names.t index 87517e9..6492f25 100644 --- a/t/storage/quote_names.t +++ b/t/storage/quote_names.t @@ -126,6 +126,14 @@ for my $db (sort { is $schema->storage->sql_maker->name_sep, $exp_name_sep, "$db name_sep with quote_names => 1 is $name_sep_text"; + + # if something was produced - it better be quoted + if ( my $ddl = try { $schema->deployment_statements } ) { + + my $quoted_artist = $schema->storage->sql_maker->_quote('artist'); + + like ($ddl, qr/^CREATE\s+TABLE\s+\Q$quoted_artist/msi, "$db DDL contains expected quoted table name"); + } } done_testing;