Adding SQL test case for SQL relationship filtering.

This commit is contained in:
mike12345567 2022-01-17 18:20:37 +00:00
parent abfa80bb47
commit 662a0cdd39
1 changed files with 16 additions and 0 deletions

View File

@ -119,6 +119,22 @@ describe("SQL query builder", () => {
}) })
}) })
it("should allow filtering on a related field", () => {
const query = sql._query(generateReadJson({
filters: {
equal: {
age: 10,
"task.name": "task 1",
},
},
}))
// order of bindings changes because relationship filters occur outside inner query
expect(query).toEqual({
bindings: [10, limit, "task 1"],
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3`
})
})
it("should test an create statement", () => { it("should test an create statement", () => {
const query = sql._query(generateCreateJson(TABLE_NAME, { const query = sql._query(generateCreateJson(TABLE_NAME, {
name: "Michael", name: "Michael",