7 use DBIC::SqlMakerTest;
10 eval "use DBD::SQLite";
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
20 my $schema = DBICTest->init_schema();
22 my $sql_maker = $schema->storage->sql_maker;
24 $sql_maker->quote_char('`');
25 $sql_maker->name_sep('.');
27 my ($sql, @bind) = $sql_maker->select(
38 'artist.artistid' => 'me.artist'
48 'artist.name' => 'Caterwauler McCrae',
58 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] ],
59 'got correct SQL and bind parameters for count query with quoting'
63 ($sql, @bind) = $sql_maker->select(
83 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year DESC`/, [],
84 'scalar ORDER BY okay (single value)'
88 ($sql, @bind) = $sql_maker->select(
111 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year DESC`, `title ASC`/, [],
112 'scalar ORDER BY okay (multiple values)'
116 skip "SQL::Abstract < 1.49 does not support hashrefs in order_by", 2
117 if $SQL::Abstract::VERSION < 1.49;
119 ($sql, @bind) = $sql_maker->select(
139 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC/, [],
140 'hashref ORDER BY okay (single value)'
144 ($sql, @bind) = $sql_maker->select(
167 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC, `title` ASC/, [],
168 'hashref ORDER BY okay (multiple values)'
174 ($sql, @bind) = $sql_maker->select(
194 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC/, [],
195 'did not quote ORDER BY with scalarref (single value)'
199 ($sql, @bind) = $sql_maker->select(
222 q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC, title ASC/, [],
223 'did not quote ORDER BY with scalarref (multiple values)'
227 ($sql, @bind) = $sql_maker->update(
237 q/UPDATE `group` SET `name` = ?, `order` = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
238 'quoted table names for UPDATE'
242 skip "select attr with star does not work in SQL::Abstract < 1.49", 1
243 if $SQL::Abstract::VERSION < 1.49;
245 ($sql, @bind) = $sql_maker->select(
262 q/SELECT `me`.* FROM `cd` `me`/, [],
263 'select attr with me.* is right'
268 $sql_maker->quote_char([qw/[ ]/]);
270 ($sql, @bind) = $sql_maker->select(
277 'artist' => 'artist',
281 'artist.artistid' => 'me.artist'
291 'artist.name' => 'Caterwauler McCrae',
301 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] ],
302 'got correct SQL and bind parameters for count query with bracket quoting'
306 ($sql, @bind) = $sql_maker->update(
316 q/UPDATE [group] SET [name] = ?, [order] = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
317 'bracket quoted table names for UPDATE'