Skip to content

Commit

Permalink
test: add between test case
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed May 2, 2017
1 parent 5bfb0ee commit b028a14
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions test/adapters/mysql_make.js
Expand Up @@ -158,6 +158,11 @@ module.exports = function(name, options) {
}, "and");
sql.should.equal("`key3` = \"{\\\"foo\\\":\\\"bar\\\"}\"");

sql = adapter.makeFieldWhere(model, "key2", {
$between: [ 1, 100 ]
}, "and");
sql.should.equal("`key2` BETWEEN 1 AND 100");

const date = new Date(0);
const dateStr = moment(0).format("YYYY-MM-DD HH:mm:ss");
sql = adapter.makeFieldWhere(model, "key5", date, "and");
Expand Down Expand Up @@ -226,17 +231,23 @@ module.exports = function(name, options) {
} }, "AND");
sql.should.equal("(`id` = 1 AND `key2` = 2 AND (`key3` = \"1\" OR `key4` = \"2\"))");

sql = adapter.makeWhere(model, { key1: "1", key2: "2", $or: [
{ key3: 1, key4: "2" },
{ $or: { key3: 2, key4: "3" } },
{ $and: { key3: 3, key4: "4" } }
], $and: [
{ $or: { key3: 1, key4: 2 } },
{ key1: 1 }
] }, "AND");
sql = adapter.makeWhere(model, {
key1: "1",
key2: "2",
$or: [
{ key3: 1, key4: "2" },
{ $or: { key3: 2, key4: "3" } },
{ $and: { key3: 3, key4: "4" } },
{ key2: { $between: [ 1, 100 ] } }
],
$and: [
{ $or: { key3: 1, key4: 2 } },
{ key1: 1 }
]
}, "AND");
sql.should.equal("(`id` = 1 AND `key2` = 2 AND ((`key3` = \"1\" AND `key4` = \"2\") OR ((`key3` = " +
"\"2\" OR `key4` = \"3\")) OR ((`key3` = \"3\" AND `key4` = \"4\"))) AND " +
"(((`key3` = \"1\" OR `key4` = \"2\")) AND (`id` = 1)))");
"\"2\" OR `key4` = \"3\")) OR ((`key3` = \"3\" AND `key4` = \"4\")) OR (`key2` BETWEEN 1 AND 100)) " +
"AND (((`key3` = \"1\" OR `key4` = \"2\")) AND (`id` = 1)))");
});

it("should generate - 2", function() {
Expand Down

0 comments on commit b028a14

Please sign in to comment.