diff --git a/packages/server/src/api/routes/tests/datasource.spec.js b/packages/server/src/api/routes/tests/datasource.spec.js index a041de4310..7387dd3c46 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.js +++ b/packages/server/src/api/routes/tests/datasource.spec.js @@ -82,7 +82,7 @@ describe("/datasources", () => { entityId: "users", }, resource: { - fields: ["name", "age"], + fields: ["users.name", "users.age"], }, filters: { string: { @@ -94,7 +94,7 @@ describe("/datasources", () => { .expect(200) // this is mock data, can't test it expect(res.body).toBeDefined() - expect(pg.queryMock).toHaveBeenCalledWith(`select "name", "age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000]) + expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000]) }) }) diff --git a/packages/server/src/integrations/tests/sql.spec.js b/packages/server/src/integrations/tests/sql.spec.js index fb57fe79e7..a02a7e8198 100644 --- a/packages/server/src/integrations/tests/sql.spec.js +++ b/packages/server/src/integrations/tests/sql.spec.js @@ -62,12 +62,13 @@ describe("SQL query builder", () => { }) it("should test a read with specific columns", () => { + const nameProp = `${TABLE_NAME}.name`, ageProp = `${TABLE_NAME}.age` const query = sql._query(generateReadJson({ - fields: ["name", "age"] + fields: [nameProp, ageProp] })) expect(query).toEqual({ bindings: [limit], - sql: `select "name", "age" from "${TABLE_NAME}" limit $1` + sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from "${TABLE_NAME}" limit $1` }) })