5 use Data::Dumper::Concise;
10 'DBIx::Class::Storage::DBI' =>
11 # no default quote_char
14 'DBIx::Class::Storage::DBI::MSSQL' =>
15 { quote_char => [ '[', ']' ], name_sep => '.' },
17 'DBIx::Class::Storage::DBI::DB2' =>
18 { quote_char => '"', name_sep => '.' },
20 'DBIx::Class::Storage::DBI::Informix' =>
21 { quote_char => '"', name_sep => '.' },
23 'DBIx::Class::Storage::DBI::InterBase' =>
24 { quote_char => '"', name_sep => '.' },
26 'DBIx::Class::Storage::DBI::mysql' =>
27 { quote_char => '`', name_sep => '.' },
29 'DBIx::Class::Storage::DBI::Pg' =>
30 { quote_char => '"', name_sep => '.' },
32 'DBIx::Class::Storage::DBI::ODBC::ACCESS' =>
33 { quote_char => [ '[', ']' ], name_sep => '.' },
35 # Not testing this one, it's a pain.
36 # 'DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL' =>
37 # { quote_char => '"', name_sep => qr/must be connected/ },
39 'DBIx::Class::Storage::DBI::Oracle::Generic' =>
40 { quote_char => '"', name_sep => '.' },
42 'DBIx::Class::Storage::DBI::SQLAnywhere' =>
43 { quote_char => '"', name_sep => '.' },
45 'DBIx::Class::Storage::DBI::SQLite' =>
46 { quote_char => '"', name_sep => '.' },
48 'DBIx::Class::Storage::DBI::Sybase::ASE' =>
49 { quote_char => [ '[', ']' ], name_sep => '.' },
52 while (my ($class, $mapping) = each %expected) {
53 my ($quote_char, $name_sep) = @$mapping{qw/quote_char name_sep/};
54 eval "require ${class};";
56 my $instance = $class->new;
58 my $quote_char_text = dumper($quote_char);
60 if (exists $mapping->{quote_char}) {
61 is_deeply $instance->sql_quote_char, $quote_char,
62 "sql_quote_char for $class is $quote_char_text";
65 is $instance->sql_name_sep, $name_sep,
66 "sql_name_sep for $class is '$name_sep'";
69 # Try quote_names with available DBs.
73 my $schema = DBICTest->init_schema(quote_names => 1);
75 is $schema->storage->sql_maker->quote_char, '"',
76 q{quote_names => 1 sets correct quote_char for SQLite ('"')};
78 is $schema->storage->sql_maker->name_sep, '.',
79 q{quote_names => 1 sets correct name_sep for SQLite (".")};
83 # Env var to base class mapping, these are the DBs I actually have.
86 ORA => 'DBIx::Class::Storage::DBI::Oracle::Generic',
87 PG => 'DBIx::Class::Storage::DBI::Pg',
88 MYSQL => 'DBIx::Class::Storage::DBI::mysql',
89 DB2 => 'DBIx::Class::Storage::DBI::DB2',
90 SYBASE => 'DBIx::Class::Storage::DBI::Sybase::ASE',
91 SQLANYWHERE => 'DBIx::Class::Storage::DBI::SQLAnywhere',
92 SQLANYWHERE_ODBC => 'DBIx::Class::Storage::DBI::SQLAnywhere',
93 FIREBIRD => 'DBIx::Class::Storage::DBI::InterBase',
94 FIREBIRD_ODBC => 'DBIx::Class::Storage::DBI::InterBase',
95 INFORMIX => 'DBIx::Class::Storage::DBI::Informix',
96 MSSQL_ODBC => 'DBIx::Class::Storage::DBI::MSSQL',
99 while (my ($db, $base_class) = each %dbs) {
100 my ($dsn, $user, $pass) = map $ENV{"DBICTEST_${db}_$_"}, qw/DSN USER PASS/;
104 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
108 my $expected_quote_char = $expected{$base_class}{quote_char};
109 my $quote_char_text = dumper($expected_quote_char);
111 is_deeply $schema->storage->sql_maker->quote_char,
112 $expected_quote_char,
113 "$db quote_char with quote_names => 1 is $quote_char_text";
115 my $expected_name_sep = $expected{$base_class}{name_sep};
117 is $schema->storage->sql_maker->name_sep,
119 "$db name_sep with quote_names => 1 is '$expected_name_sep'";
127 my $dd = DumperObject;
129 return $dd->Values([ $val ])->Dump;