From: Peter Rabbitson Date: Wed, 30 Jul 2014 11:48:22 +0000 (+0200) Subject: Ensure proper behavior when quoting is *disabled* (wraps up 08ac7648) X-Git-Tag: v0.082800~89 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=111364b30f1418813dec58ac6aca4492476bd23b Ensure proper behavior when quoting is *disabled* (wraps up 08ac7648) --- diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 5b5181f..6213c8b 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -44,8 +44,16 @@ use namespace::clean; __PACKAGE__->mk_group_accessors (simple => qw/quote_char name_sep limit_dialect/); +sub _quoting_enabled { + ( defined $_[0]->{quote_char} and length $_[0]->{quote_char} ) ? 1 : 0 +} + # for when I need a normalized l/r pair sub _quote_chars { + + # in case we are called in the old !!$sm->_quote_chars fashion + return () if !wantarray and ( ! defined $_[0]->{quote_char} or ! length $_[0]->{quote_char} ); + map { defined $_ ? $_ : '' } ( ref $_[0]->{quote_char} ? (@{$_[0]->{quote_char}}) : ( ($_[0]->{quote_char}) x 2 ) ) diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index bd201a1..4c815f0 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2872,7 +2872,7 @@ sub create_ddl_dir { add_drop_table => 1, ignore_constraint_names => 1, ignore_index_names => 1, - quote_identifiers => !!$self->sql_maker->_quote_chars, + quote_identifiers => $self->sql_maker->_quoting_enabled, %{$sqltargs || {}} }; @@ -3041,9 +3041,8 @@ sub deployment_statements { $sqltargs->{parser_args}{sources} = delete $sqltargs->{sources} if exists $sqltargs->{sources}; - $sqltargs->{quote_identifiers} - = !!$self->sql_maker->_quote_chars - if ! exists $sqltargs->{quote_identifiers}; + $sqltargs->{quote_identifiers} = $self->sql_maker->_quoting_enabled + unless exists $sqltargs->{quote_identifiers}; my $tr = SQL::Translator->new( producer => "SQL::Translator::Producer::${type}", diff --git a/t/86sqlt.t b/t/86sqlt.t index 87b90a5..eccc5e2 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 $schema = DBICTest->init_schema (no_deploy => 1, quote_names => 1); my $not_first_table_creation_re = qr/CREATE TABLE "fourkeys_to_twokeys"/; my $statements = $schema->deployment_statements; diff --git a/t/storage/deploy.t b/t/storage/deploy.t index 46e6a36..61610ba 100644 --- a/t/storage/deploy.t +++ b/t/storage/deploy.t @@ -22,7 +22,7 @@ local $ENV{DBI_DSN}; # there ought to be more code like this in the wild like( DBICTest::Schema->connect->deployment_statements('SQLite'), - qr/\bCREATE TABLE\b/i + qr/\bCREATE TABLE artist\b/i # ensure quoting *is* disabled ); lives_ok( sub {