Skip to content

Commit 91dff99

Browse files
authored
Allow using Date as a value (#26)
1 parent a1715b2 commit 91dff99

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/index.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,20 @@ describe("sql template tag", () => {
9494
expect(query.values).toEqual([]);
9595
});
9696
});
97+
98+
describe("value typing", () => {
99+
it.each([
100+
["string", "Blake"],
101+
["number", 123],
102+
["boolean", true],
103+
["Date", new Date("2010-01-01T00:00:00Z")],
104+
["null", null],
105+
["undefined", undefined],
106+
["string array", ["Blake", "Taylor"]],
107+
["object", { name: "Blake" }],
108+
])("should allow using %s as a value", (_type, value) => {
109+
const query = sql`UPDATE user SET any_value = ${value}`;
110+
expect(query.values).toEqual([value]);
111+
});
112+
});
97113
});

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type Value =
22
| string
33
| number
44
| boolean
5+
| Date
56
| null
67
| undefined
78
| Value[]

0 commit comments

Comments
 (0)