7 use DBIC::SqlMakerTest;
10 eval "use DBD::SQLite";
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
18 my $schema = DBICTest->init_schema();
20 my $sql_maker = $schema->storage->sql_maker;
22 $sql_maker->quote_char('`');
23 $sql_maker->name_sep('.');
25 my ($sql, @bind) = $sql_maker->select(
36 'artist.artistid' => 'me.artist'
46 'artist.name' => 'Caterwauler McCrae',
56 q/SELECT COUNT( * ) FROM `cd` `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/, [ ['artist.name' => 'Caterwauler McCrae'], ['me.year' => 2001] ],
57 'got correct SQL and bind parameters for count query with quoting'
61 ($sql, @bind) = $sql_maker->select(
81 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year DESC`/, [],
82 'scalar ORDER BY okay (single value)'
86 ($sql, @bind) = $sql_maker->select(
109 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year DESC`, `title ASC`/, [],
110 'scalar ORDER BY okay (multiple values)'
114 ($sql, @bind) = $sql_maker->select(
134 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC/, [],
135 'hashref ORDER BY okay (single value)'
139 ($sql, @bind) = $sql_maker->select(
162 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC, `title` ASC/, [],
163 'hashref ORDER BY okay (multiple values)'
169 ($sql, @bind) = $sql_maker->select(
189 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC/, [],
190 'did not quote ORDER BY with scalarref (single value)'
194 ($sql, @bind) = $sql_maker->select(
217 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC, title ASC/, [],
218 'did not quote ORDER BY with scalarref (multiple values)'
222 ($sql, @bind) = $sql_maker->update(
232 q/UPDATE `group` SET `name` = ?, `order` = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
233 'quoted table names for UPDATE'
237 ($sql, @bind) = $sql_maker->select(
254 q/SELECT `me`.* FROM `cd` `me`/, [],
255 'select attr with me.* is right'
260 $sql_maker->quote_char([qw/[ ]/]);
262 ($sql, @bind) = $sql_maker->select(
269 'artist' => 'artist',
273 'artist.artistid' => 'me.artist'
283 'artist.name' => 'Caterwauler McCrae',
293 q/SELECT COUNT( * ) FROM [cd] [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/, [ ['artist.name' => 'Caterwauler McCrae'], ['me.year' => 2001] ],
294 'got correct SQL and bind parameters for count query with bracket quoting'
298 ($sql, @bind) = $sql_maker->update(
308 q/UPDATE [group] SET [name] = ?, [order] = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
309 'bracket quoted table names for UPDATE'