diff --git a/packages/server/src/api/routes/tests/table.spec.ts b/packages/server/src/api/routes/tests/table.spec.ts index 059b5cde72..f23e0de6db 100644 --- a/packages/server/src/api/routes/tests/table.spec.ts +++ b/packages/server/src/api/routes/tests/table.spec.ts @@ -52,14 +52,24 @@ describe.each([ jest.clearAllMocks() }) - it("creates a table successfully", async () => { - const name = generator.guid() + it.each([ + "alphanum", + "with spaces", + "with-dashes", + "with_underscores", + 'with "double quotes"', + "with 'single quotes'", + "with `backticks`", + ])("creates a table with name: %s", async name => { const table = await config.api.table.save( tableForDatasource(datasource, { name }) ) expect(table.name).toEqual(name) expect(events.table.created).toHaveBeenCalledTimes(1) expect(events.table.created).toHaveBeenCalledWith(table) + + const res = await config.api.table.get(table._id!) + expect(res.name).toEqual(name) }) it("creates a table via data import", async () => { diff --git a/packages/server/src/integrations/tests/sql.spec.ts b/packages/server/src/integrations/tests/sql.spec.ts index 78f6cd5d57..cf433725ce 100644 --- a/packages/server/src/integrations/tests/sql.spec.ts +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -228,6 +228,51 @@ describe("SQL query builder", () => { }) }) + it("should lowercase the values for Oracle LIKE statements", () => { + let query = new Sql(SqlClient.ORACLE, limit)._query( + generateReadJson({ + filters: { + string: { + name: "John", + }, + }, + }) + ) + expect(query).toEqual({ + bindings: ["john%", limit], + sql: `select * from (select * from (select * from "test" where LOWER("test"."name") LIKE :1) where rownum <= :2) "test"`, + }) + + query = new Sql(SqlClient.ORACLE, limit)._query( + generateReadJson({ + filters: { + contains: { + age: [20, 25], + name: ["John", "Mary"], + }, + }, + }) + ) + expect(query).toEqual({ + bindings: ["%20%", "%25%", `%"john"%`, `%"mary"%`, limit], + sql: `select * from (select * from (select * from "test" where (LOWER("test"."age") LIKE :1 AND LOWER("test"."age") LIKE :2) and (LOWER("test"."name") LIKE :3 AND LOWER("test"."name") LIKE :4)) where rownum <= :5) "test"`, + }) + + query = new Sql(SqlClient.ORACLE, limit)._query( + generateReadJson({ + filters: { + fuzzy: { + name: "Jo", + }, + }, + }) + ) + expect(query).toEqual({ + bindings: [`%jo%`, limit], + sql: `select * from (select * from (select * from "test" where LOWER("test"."name") LIKE :1) where rownum <= :2) "test"`, + }) + }) + it("should sort SQL Server tables by the primary key if no sort data is provided", () => { let query = new Sql(SqlClient.MS_SQL, limit)._query( generateReadJson({