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

Commit 64c5528f by Mathieu Amiot

Fixed a code style issue in mysql query generator unit tests

Added Postgres and SQLite unit tests
1 parent 9f769203
...@@ -235,7 +235,7 @@ if (Support.dialectIsMySQL()) { ...@@ -235,7 +235,7 @@ if (Support.dialectIsMySQL()) {
arguments: ['myTable', {group: "name", order: "id DESC"}], arguments: ['myTable', {group: "name", order: "id DESC"}],
expectation: "SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;", expectation: "SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;",
context: QueryGenerator context: QueryGenerator
},{ }, {
title: 'HAVING clause works with string replacements', title: 'HAVING clause works with string replacements',
arguments: ['myTable', function (sequelize) { arguments: ['myTable', function (sequelize) {
return { return {
......
...@@ -318,6 +318,30 @@ if (dialect.match(/^postgres/)) { ...@@ -318,6 +318,30 @@ if (dialect.match(/^postgres/)) {
arguments: ['myTable', {group: ["name","title"]}], arguments: ['myTable', {group: ["name","title"]}],
expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\", \"title\";" expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\", \"title\";"
}, { }, {
title: 'HAVING clause works with string replacements',
arguments: ['myTable', function (sequelize) {
return {
attributes: ['*', [sequelize.fn('YEAR', sequelize.col('createdAt')), 'creationYear']],
group: ['creationYear', 'title'],
having: ['creationYear > ?', 2002]
}
}],
expectation: "SELECT *, YEAR(\"createdAt\") as \"creationYear\" FROM \"myTable\" GROUP BY \"creationYear\", \"title\" HAVING creationYear > 2002;",
context: QueryGenerator,
needsSequelize: true
}, {
title: 'HAVING clause works with where-like hash',
arguments: ['myTable', function (sequelize) {
return {
attributes: ['*', [sequelize.fn('YEAR', sequelize.col('createdAt')), 'creationYear']],
group: ['creationYear', 'title'],
having: { creationYear: { gt: 2002 } }
}
}],
expectation: "SELECT *, YEAR(\"createdAt\") as \"creationYear\" FROM \"myTable\" GROUP BY \"creationYear\", \"title\" HAVING \"creationYear\" > 2002;",
context: QueryGenerator,
needsSequelize: true
}, {
arguments: ['myTable', {limit: 10}], arguments: ['myTable', {limit: 10}],
expectation: "SELECT * FROM \"myTable\" LIMIT 10;" expectation: "SELECT * FROM \"myTable\" LIMIT 10;"
}, { }, {
......
...@@ -223,6 +223,30 @@ if (dialect === 'sqlite') { ...@@ -223,6 +223,30 @@ if (dialect === 'sqlite') {
expectation: "SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;", expectation: "SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;",
context: QueryGenerator context: QueryGenerator
}, { }, {
title: 'HAVING clause works with string replacements',
arguments: ['myTable', function (sequelize) {
return {
attributes: ['*', [sequelize.fn('YEAR', sequelize.col('createdAt')), 'creationYear']],
group: ['creationYear', 'title'],
having: ['creationYear > ?', 2002]
}
}],
expectation: "SELECT *, YEAR(`createdAt`) as `creationYear` FROM `myTable` GROUP BY `creationYear`, `title` HAVING creationYear > 2002;",
context: QueryGenerator,
needsSequelize: true
}, {
title: 'HAVING clause works with where-like hash',
arguments: ['myTable', function (sequelize) {
return {
attributes: ['*', [sequelize.fn('YEAR', sequelize.col('createdAt')), 'creationYear']],
group: ['creationYear', 'title'],
having: { creationYear: { gt: 2002 } }
}
}],
expectation: "SELECT *, YEAR(`createdAt`) as `creationYear` FROM `myTable` GROUP BY `creationYear`, `title` HAVING `creationYear` > 2002;",
context: QueryGenerator,
needsSequelize: true
}, {
arguments: ['myTable', {limit: 10}], arguments: ['myTable', {limit: 10}],
expectation: "SELECT * FROM `myTable` LIMIT 10;", expectation: "SELECT * FROM `myTable` LIMIT 10;",
context: QueryGenerator context: QueryGenerator
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!