use DBIx::Class::Carp;
use namespace::clean;
-__PACKAGE__->mk_group_accessors (simple => qw/quote_char name_sep limit_dialect/);
+__PACKAGE__->mk_group_accessors (simple => qw/quote_char escape_char name_sep limit_dialect/);
# for when I need a normalized l/r pair
sub _quote_chars {
);
isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
lives_ok { $admin->create('MySQL'); } 'Can create MySQL sql';
-lives_ok { $admin->create('SQLite'); } 'Can Create SQLite sql';
+lives_ok { $admin->create('SQLite', {quote_identifiers=>1}); } 'Can Create SQLite sql';
lives_ok {
local $SIG{__WARN__} = sigwarn_silencer( qr/no such table.+DROP TABLE/s );
$admin->deploy()
),
qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/,
qw/Collection CollectionObject TypedObject Owners BooksInLibrary/,
- qw/ForceForeign Encoded/,
+ qw/ForceForeign Encoded Quotes/,
);
sub sqlt_deploy_hook {
--- /dev/null
+package # hide from PAUSE
+ DBICTest::Schema::Quotes;
+
+use warnings;
+use strict;
+
+use base 'DBICTest::BaseResult';
+
+# Include all the common quote characters
+__PACKAGE__->table('`with` [some] "quotes"');
+
+__PACKAGE__->add_columns(
+ '`has` [more] "quotes"' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ accessor => 'has_more_quotes',
+ },
+);
+
+1;
+CREATE TABLE "`with` [some] ""quotes""" (
+ "`has` [more] ""quotes""" integer NOT NULL
+);
+
CREATE TABLE "artist" (
"artistid" INTEGER PRIMARY KEY NOT NULL,
"name" varchar(100),
'got correct SQL for count query with bracket quoting'
);
+is_same_sql_bind(
+ $schema->resultset('Quotes')->search({})->as_query,
+ '(SELECT [me].[`has` [more]] "quotes"] FROM [`with` [some]] "quotes"] [me])',
+ [],
+ 'got correct escaped quotes with bracket quoting'
+);
+
$schema->storage->sql_maker->quote_char('`');
$schema->storage->sql_maker->name_sep('.');
'got correct SQL for count query with mysql quoting'
);
+is_same_sql_bind(
+ $schema->resultset('Quotes')->search({})->as_query,
+ '(SELECT `me`.```has`` [more] "quotes"` FROM ```with`` [some] "quotes"` `me`)',
+ [],
+ 'got correct escaped quotes with mysql quoting'
+);
+
# !!! talk to ribasushi *explicitly* before modfying these tests !!!
{
is_same_sql_bind(
# if something was produced - it better be quoted
if ( my $ddl = try { $schema->deployment_statements } ) {
- my $quoted_artist = $schema->storage->sql_maker->_quote('artist');
+ my $quoted_table = $schema->storage->sql_maker->_quote($schema->source('Quotes')->from);
- like ($ddl, qr/^CREATE\s+TABLE\s+\Q$quoted_artist/msi, "$db DDL contains expected quoted table name");
+ like ($ddl, qr/^CREATE\s+TABLE\s+\Q$quoted_table/msi, "$db DDL contains expected quoted table name");
}
}