Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1",
operator: "=",
value: "value1",
id: expect.any(String),
},
{
field: "field2",
operator: "!=",
value: "value2",
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1",
operator: "=",
value: "value1",
id: expect.any(String),
},
{
field: "field2",
operator: "!=",
value: "value2",
id: expect.any(String),
},
],
},
],
});
Expand Down Expand Up @@ -169,9 +174,14 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1",
operator: "null",
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1",
operator: "null",
id: expect.any(String),
},
],
},
],
});
Expand Down Expand Up @@ -201,10 +211,15 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1.field2",
operator: queryBuilderOperator,
value: "testValue",
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1.field2",
operator: queryBuilderOperator,
value: "testValue",
id: expect.any(String),
},
],
},
],
});
Expand All @@ -227,9 +242,14 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1.field2",
operator: "notNull",
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1.field2",
operator: "notNull",
id: expect.any(String),
},
],
},
],
});
Expand All @@ -253,10 +273,15 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1",
operator: "notIn",
value: [1, 2, 3],
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1",
operator: "notIn",
value: [1, 2, 3],
id: expect.any(String),
},
],
},
],
});
Expand Down Expand Up @@ -286,10 +311,15 @@ describe("convertCelAstToQueryBuilderAst", () => {
combinator: "and",
rules: [
{
field: "field1",
operator: queryBuilderOperator,
value: "testValue",
id: expect.any(String),
combinator: "and",
rules: [
{
field: "field1",
operator: queryBuilderOperator,
value: "testValue",
id: expect.any(String),
},
],
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export function visitCelAstNode(node: CelAst.Node): DefaultRuleGroupType {
export function convertCelAstToQueryBuilderAst(
node: CelAst.Node
): DefaultRuleGroupType {
const rulesGroup = visitCelAstNode(node);
let rulesGroup = visitCelAstNode(node);

if (rulesGroup.combinator === "or") {
// React Query Builder requires all rules to be within "and" combinator groups to function correctly.
Expand All @@ -192,5 +192,12 @@ export function convertCelAstToQueryBuilderAst(
});
}

if (rulesGroup.combinator == "and") {
rulesGroup = {
combinator: "and",
rules: [rulesGroup],
};
}

return rulesGroup;
}
Loading