diff --git a/src/safe-string.ts b/src/safe-string.ts index 33f36b7..bd78f94 100644 --- a/src/safe-string.ts +++ b/src/safe-string.ts @@ -129,20 +129,26 @@ export class SafeString { * @since 2.0.8 */ in(other: SqlSupportedTypes): SafeString { - return dsql`(${this} IN (${other}))`; + return dsql`(${this} IN ${other})`; } /** * @since 2.0.8 */ notIn(other: SqlSupportedTypes): SafeString { - return dsql`(${this} NOT IN (${other}))`; + return dsql`(${this} NOT IN ${other})`; } + /** + * @since 2.0.8 + */ asc(): SafeString { return dsql`${this} ASC`; } + /** + * @since 2.0.8 + */ desc(): SafeString { return dsql`${this} DESC`; } diff --git a/tests/unit/safe-string.test.ts b/tests/unit/safe-string.test.ts index afbcca3..c56eee4 100644 --- a/tests/unit/safe-string.test.ts +++ b/tests/unit/safe-string.test.ts @@ -9,6 +9,14 @@ describe("castSafe", () => { }); }); +describe("serialize array", () => { + it("works", () => { + expect(dsql(["a", "b", "c"]).content).toMatchInlineSnapshot(`abc`); + expect(dsql`${["a", "b", "c"]}`.content).toMatchInlineSnapshot( + `'a', 'b', 'c'` + ); + }); +}); describe("chaining", () => { it("works", () => { const base = dsql`base`; @@ -31,6 +39,14 @@ describe("chaining", () => { expect(base.multiply(1).divide(2).content).toMatchInlineSnapshot( `((base * 1) / 2)` ); + + expect(base.desc().content).toMatchInlineSnapshot(`base DESC`); + expect(base.asc().content).toMatchInlineSnapshot(`base ASC`); + + expect(base.in("a").content).toMatchInlineSnapshot(`(base IN 'a')`); + expect(base.notIn("a").content).toMatchInlineSnapshot( + `(base NOT IN 'a')` + ); }); });