Skip to content

Commit 8d6566f

Browse files
authored
fix: Query conditions inQuery and notInQuery not working properly (#869)
1 parent d1b07fe commit 8d6566f

File tree

5 files changed

+68
-4
lines changed

5 files changed

+68
-4
lines changed

packages/dart/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [5.1.1](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-5.1.0...dart-5.1.1) (2023-05-17)
2+
3+
### Bug Fixes
4+
5+
* Query conditions `inQuery` and `notInQuery` not working properly ([#869](https://github.com/parse-community/Parse-SDK-Flutter/pull/869))
6+
17
## [5.1.0](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-5.0.0...dart-5.1.0) (2023-05-14)
28

39
### Features

packages/dart/lib/src/base/parse_constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of flutter_parse_sdk;
22

33
// Library
4-
const String keySdkVersion = '5.1.0';
4+
const String keySdkVersion = '5.1.1';
55
const String keyLibraryName = 'Flutter Parse SDK';
66

77
// End Points

packages/dart/lib/src/network/parse_query.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class QueryBuilder<T extends ParseObject> {
420420
/// Builds the query relational for Parse
421421
String _buildQueryRelational(String className) {
422422
queries = _checkForMultipleColumnInstances(queries);
423-
return '{"where":{${buildQueries(queries)}},"className":"$className"${getLimitersRelational(limiters)}}';
423+
return '{"where":{${buildQueries(queries)}},"className":"$className",${getLimitersRelational(limiters)}}';
424424
}
425425

426426
/// Builds the query relational with Key for Parse

packages/dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: parse_server_sdk
22
description: The Dart SDK to connect to Parse Server. Build your apps faster with Parse Platform, the complete application stack.
3-
version: 5.1.0
3+
version: 5.1.1
44
homepage: https://github.com/parse-community/Parse-SDK-Flutter
55

66
environment:

packages/dart/test/src/network/parse_query_test.dart

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:convert';
2-
32
import 'package:mockito/annotations.dart';
43
import 'package:mockito/mockito.dart';
54
import 'package:parse_server_sdk/parse_server_sdk.dart';
@@ -407,5 +406,64 @@ void main() {
407406

408407
expect(query, equals('where={}&redirectClassNameForKey=Plan'));
409408
});
409+
410+
test('whereMatchesQuery', () async {
411+
// arrange
412+
ParseObject object2 = ParseObject("object2");
413+
final query2 = QueryBuilder<ParseObject>(object2)
414+
..includeObject(["avatar"])
415+
..whereEqualTo("firstName", "Oliver1");
416+
417+
ParseObject object1 = ParseObject("object1");
418+
final query1 = QueryBuilder<ParseObject>(object1)
419+
..includeObject(["user"])
420+
..whereEqualTo("id", "1122")
421+
..whereMatchesQuery("object2", query2);
422+
423+
ParseObject objectMain = ParseObject("objectMain", client: client);
424+
final mainQuery = QueryBuilder<ParseObject>(objectMain)
425+
..includeObject(["img"])
426+
..whereMatchesQuery("object1", query1);
427+
428+
var desiredOutput = {
429+
"results": [
430+
{
431+
"className": "_User",
432+
"objectId": "fqx5BECOME",
433+
"createdAt": "2022-10-25T06:04:47.138Z",
434+
"updatedAt": "2022-10-25T06:05:22.328Z",
435+
"firstName": "Oliver1",
436+
"lastName": "Smith1",
437+
},
438+
{
439+
"className": "_User",
440+
"objectId": "hAtRRYGrUO",
441+
"createdAt": "2022-01-24T15:53:48.396Z",
442+
"updatedAt": "2022-01-25T05:52:01.701Z",
443+
"firstName": "Oliver2",
444+
"lastName": "Smith2",
445+
},
446+
]
447+
};
448+
449+
when(client.get(
450+
any,
451+
options: anyNamed("options"),
452+
onReceiveProgress: anyNamed("onReceiveProgress"),
453+
)).thenAnswer((_) async => ParseNetworkResponse(
454+
statusCode: 200, data: jsonEncode(desiredOutput)));
455+
456+
// act
457+
await mainQuery.query();
458+
459+
final Uri result = Uri.parse(verify(client.get(
460+
captureAny,
461+
options: anyNamed("options"),
462+
onReceiveProgress: anyNamed("onReceiveProgress"),
463+
)).captured.single);
464+
465+
// assert
466+
expect(result.query.contains("%22object2%22,%22include%22"), true);
467+
});
410468
});
411469
}

0 commit comments

Comments
 (0)