Skip to content

Commit

Permalink
tests for simple _or and _and clauses (#40)
Browse files Browse the repository at this point in the history
tests for simple `_or` and `_and` clauses
  • Loading branch information
m-Bilal authored Jan 1, 2025
2 parents f31e402 + 68ddba6 commit de37e0d
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 0 deletions.
8 changes: 8 additions & 0 deletions connector/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ var tests = []test{
group: "payments",
name: "simple_where_not_clause",
},
{
group: "payments",
name: "simple_and_clause",
},
{
group: "payments",
name: "simple_or_clause",
},
}

func TestPrepareElasticsearchQuery(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"arguments": {},
"collection": "customers",
"collection_relationships": {},
"query": {
"fields": {
"customerId": {
"column": "customer_id",
"type": "column"
},
"email": {
"column": "email",
"type": "column"
},
"name": {
"column": "name",
"type": "column"
}
},
"predicate": {
"expressions": [
{
"column": {
"type": "column",
"name": "customer_id"
},
"operator": "term",
"type": "binary_comparison_operator",
"value": {
"type": "scalar",
"value": "CUST005"
}
},
{
"column": {
"type": "column",
"name": "email"
},
"operator": "match",
"type": "binary_comparison_operator",
"value": {
"type": "scalar",
"value": "[email protected]"
}
}
],
"type": "and"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query MyQuery {
customers(
where: {
_and: [
{ customerId: {term: "CUST005"} },
{ email: {match: "[email protected]"} }
]
}) {
customerId
name
email
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"_source": [
"customer_id",
"email",
"name"
],
"query": {
"bool": {
"must": [
{
"term": {
"customer_id": "CUST005"
}
},
{
"match": {
"email": "[email protected]"
}
}
]
}
},
"size": 10000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"arguments": {},
"collection": "customers",
"collection_relationships": {},
"query": {
"fields": {
"customerId": {
"column": "customer_id",
"type": "column"
},
"email": {
"column": "email",
"type": "column"
},
"name": {
"column": "name",
"type": "column"
}
},
"predicate": {
"expressions": [
{
"column": {
"type": "column",
"name": "customer_id"
},
"operator": "term",
"type": "binary_comparison_operator",
"value": {
"type": "scalar",
"value": "CUST005"
}
},
{
"column": {
"type": "column",
"name": "customer_id"
},
"operator": "term",
"type": "binary_comparison_operator",
"value": {
"type": "scalar",
"value": "CUST006"
}
}
],
"type": "or"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query MyQuery {
customers(where: {
_or: [
{ customerId: {term: "CUST005"} },
{ customerId: {term: "CUST006"} }
]
}) {
customerId
name
email
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"_source": [
"customer_id",
"email",
"name"
],
"query": {
"bool": {
"should": [
{
"term": {
"customer_id": "CUST005"
}
},
{
"term": {
"customer_id": "CUST006"
}
}
]
}
},
"size": 10000
}

0 comments on commit de37e0d

Please sign in to comment.