Skip to content

Commit 0c46321

Browse files
committed
add Where_string_contains
1 parent 90f8103 commit 0c46321

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
target:
3+
{
4+
"data": {
5+
"stringEntities": [
6+
{
7+
"id": "Guid_1",
8+
"property": "b"
9+
},
10+
{
11+
"id": "Guid_2",
12+
"property": "ab"
13+
},
14+
{
15+
"id": "Guid_3",
16+
"property": "bc"
17+
},
18+
{
19+
"id": "Guid_4",
20+
"property": "abc"
21+
}
22+
]
23+
}
24+
},
25+
sql: {
26+
Text:
27+
select s.Id,
28+
s.Property
29+
from StringEntities as s
30+
where s.Property is not null
31+
and cast (CHARINDEX(N'b', s.Property) as int) - 1 <> -1
32+
}
33+
}

src/Tests/IntegrationTests/IntegrationTests.Where_string_notEqual.verified.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"data": {
55
"stringEntities": [
66
{
7-
"id": "Guid_1"
7+
"id": "Guid_1",
8+
"property": "Value"
89
},
910
{
10-
"id": "Guid_2"
11+
"id": "Guid_2",
12+
"property": null
1113
}
1214
]
1315
}

src/Tests/IntegrationTests/IntegrationTests.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public async Task Where_string_notEqual()
223223
{
224224
stringEntities (where: {path: "Property", comparison: notEqual, value: "notValue"})
225225
{
226-
id
226+
id, property
227227
}
228228
}
229229
""";
@@ -242,6 +242,53 @@ public async Task Where_string_notEqual()
242242
await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]);
243243
}
244244

245+
[Fact]
246+
public async Task Where_string_contains()
247+
{
248+
var query =
249+
"""
250+
{
251+
stringEntities (where: {path: "Property", comparison: contains, value: "b" })
252+
{
253+
id, property
254+
}
255+
}
256+
""";
257+
258+
var entity1 = new StringEntity();
259+
var entity2 = new StringEntity
260+
{
261+
Property = "a"
262+
};
263+
var entity3 = new StringEntity
264+
{
265+
Property = "ab"
266+
};
267+
var entity4 = new StringEntity
268+
{
269+
Property = "abc"
270+
};
271+
var entity5 = new StringEntity
272+
{
273+
Property = "bc"
274+
};
275+
var entity6 = new StringEntity
276+
{
277+
Property = "c"
278+
};
279+
var entity7 = new StringEntity
280+
{
281+
Property = "b"
282+
};
283+
var entity8 = new StringEntity
284+
{
285+
Property = ""
286+
};
287+
288+
await using var database = await sqlInstance.Build();
289+
await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5, entity6, entity7, entity8]);
290+
}
291+
245292
[Fact]
246293
public async Task Where_enum_in()
247294
{

0 commit comments

Comments
 (0)