不要怂,就是干,撸起袖子干!

Commit 29c1ac01 by Sascha Depold

fixed the context of the selectQuery tests

1 parent 1fa63824
Showing with 26 additions and 13 deletions
...@@ -35,44 +35,57 @@ describe('QueryGenerator', function() { ...@@ -35,44 +35,57 @@ describe('QueryGenerator', function() {
selectQuery: [ selectQuery: [
{ {
arguments: ['myTable'], arguments: ['myTable'],
expectation: "SELECT * FROM `myTable`;" expectation: "SELECT * FROM `myTable`;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {attributes: ['id', 'name']}], arguments: ['myTable', {attributes: ['id', 'name']}],
expectation: "SELECT `id`, `name` FROM `myTable`;" expectation: "SELECT `id`, `name` FROM `myTable`;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {where: {id: 2}}], arguments: ['myTable', {where: {id: 2}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`id`=2;" expectation: "SELECT * FROM `myTable` WHERE `myTable`.`id`=2;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {where: {name: 'foo'}}], arguments: ['myTable', {where: {name: 'foo'}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`name`='foo';" expectation: "SELECT * FROM `myTable` WHERE `myTable`.`name`='foo';",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {where: {name: "foo';DROP TABLE myTable;"}}], arguments: ['myTable', {where: {name: "foo';DROP TABLE myTable;"}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`name`='foo\\';DROP TABLE myTable;';" expectation: "SELECT * FROM `myTable` WHERE `myTable`.`name`='foo\\';DROP TABLE myTable;';",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {where: 2}], arguments: ['myTable', {where: 2}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`id`=2;" expectation: "SELECT * FROM `myTable` WHERE `myTable`.`id`=2;",
context: QueryGenerator
}, { }, {
arguments: ['foo', { attributes: [['count(*)', 'count']] }], arguments: ['foo', { attributes: [['count(*)', 'count']] }],
expectation: 'SELECT count(*) as `count` FROM `foo`;' expectation: 'SELECT count(*) as `count` FROM `foo`;',
context: QueryGenerator
}, { }, {
arguments: ['myTable', {where: "foo='bar'"}], arguments: ['myTable', {where: "foo='bar'"}],
expectation: "SELECT * FROM `myTable` WHERE foo='bar';" expectation: "SELECT * FROM `myTable` WHERE foo='bar';",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {order: "id DESC"}], arguments: ['myTable', {order: "id DESC"}],
expectation: "SELECT * FROM `myTable` ORDER BY id DESC;" expectation: "SELECT * FROM `myTable` ORDER BY id DESC;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {group: "name"}], arguments: ['myTable', {group: "name"}],
expectation: "SELECT * FROM `myTable` GROUP BY `name`;" expectation: "SELECT * FROM `myTable` GROUP BY `name`;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {limit: 10}], arguments: ['myTable', {limit: 10}],
expectation: "SELECT * FROM `myTable` LIMIT 10;" expectation: "SELECT * FROM `myTable` LIMIT 10;",
context: QueryGenerator
}, { }, {
arguments: ['myTable', {limit: 10, offset: 2}], arguments: ['myTable', {limit: 10, offset: 2}],
expectation: "SELECT * FROM `myTable` LIMIT 2, 10;" expectation: "SELECT * FROM `myTable` LIMIT 2, 10;",
context: QueryGenerator
}, { }, {
title: 'ignores offset if no limit was passed', title: 'ignores offset if no limit was passed',
arguments: ['myTable', {offset: 2}], arguments: ['myTable', {offset: 2}],
expectation: "SELECT * FROM `myTable`;" expectation: "SELECT * FROM `myTable`;",
context: QueryGenerator
} }
], ],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!