-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1506f21
commit ec6439e
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Cond } from "../Condition"; | ||
import { Fn } from "../Function"; | ||
import { Q } from "../Query"; | ||
import { DefaultFlavor } from "./default"; | ||
|
||
const flavor = new DefaultFlavor(); | ||
|
||
describe("Default Flavor flavor", () => { | ||
it("should render correct select", () => { | ||
const query = Q.select() | ||
.addField("foo", "blah") | ||
.addField(Fn.max("foo"), "blahMax") | ||
.from("table") | ||
.where(Cond.equal("foo", 123)) | ||
.where(Cond.equal("blah", "hello")) | ||
.orderBy("foo", "DESC") | ||
.limit(100) | ||
.offset(2); | ||
expect(query.toSQL(flavor)).toEqual( | ||
'SELECT `foo` AS `blah`, MAX(`foo`) AS `blahMax` FROM `table` WHERE `foo` = 123 AND `blah` = "hello" ORDER BY `foo` DESC LIMIT 100 OFFSET 2' | ||
); | ||
}); | ||
it("should render correct update", () => { | ||
const query = Q.update("table").set({ foo: `'aa'xx"` }); | ||
expect(query.toSQL(flavor)).toEqual( | ||
'UPDATE `table` SET `foo` = "\'aa\'xx"""' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Cond } from "../Condition"; | ||
import { Fn } from "../Function"; | ||
import { Q } from "../Query"; | ||
import { DefaultFlavor } from "./default"; | ||
|
||
const flavor = Q.flavors.sqlite; | ||
|
||
describe("SQLite Flavor flavor", () => { | ||
it("should render correct select", () => { | ||
const query = Q.select() | ||
.addField("foo", "blah") | ||
.addField(Fn.max("foo"), "blahMax") | ||
.from("table") | ||
.where(Cond.equal("foo", 123)) | ||
.where(Cond.equal("blah", "hello")) | ||
.orderBy("foo", "DESC") | ||
.limit(100) | ||
.offset(2); | ||
expect(query.toSQL(flavor)).toEqual( | ||
"SELECT `foo` AS `blah`, MAX(`foo`) AS `blahMax` FROM `table` WHERE `foo` = 123 AND `blah` = 'hello' ORDER BY `foo` DESC LIMIT 100 OFFSET 2" | ||
); | ||
}); | ||
it("should render correct update", () => { | ||
const query = Q.update("table").set({ foo: `'aa'xx"` }); | ||
expect(query.toSQL(flavor)).toEqual( | ||
"UPDATE `table` SET `foo` = '''aa''xx\"'" | ||
); | ||
}); | ||
}); |