1
0
Fork 0
mirror of synced 2024-06-30 12:00:31 +12:00

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

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", () => {
const query = sql._query(generateCreateJson(TABLE_NAME, {
name: "Michael",