parse-community / Parse-SDK-Flutter

The Dart/Flutter SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
573 stars 188 forks source link

Join or and pure query #951

Open catalunha opened 1 year ago

catalunha commented 1 year ago

New Issue Checklist

Issue Description

Hello Masters,

I'm trying to solve a query and I'm not succeeding. And I've done a lot of testing. I hope to get your precious time and experience to see if this has a solution. The following snippet gives me a list of all calls made by user hE0Ng2FSwQ:

   final QueryBuilder<ParseObject> queryAttendance =
       QueryBuilder<ParseObject>(ParseObject(AttendanceEntity.className));
   queryAttendance.whereEqualTo(
       AttendanceEntity.professional,
       (ParseObject(UserProfileEntity.className)..objectId = 'hE0Ng2FSwQ')
           .toPointer());

   final list = await AttendanceB4a().list(
     queryAttendance,
     cols: {
       "${AttendanceEntity.className}.cols": [AttendanceEntity.id]
     },
   );

The following snippet gives me all the events that belong to that user's previous calls.

   List<QueryBuilder<ParseObject>> listQueries = [];
   for (var element in list) {
     final QueryBuilder<ParseObject> queryTemp =
         QueryBuilder<ParseObject>(ParseObject(EventEntity.className));
       queryTemp.whereEqualTo(
         EventEntity.attendances,
         (ParseObject(AttendanceEntity.className)..objectId = element.id)
             .toPointer());
     listQueries.add(queryTemp);
   }
   QueryBuilder<ParseObject> eventsByUser = QueryBuilder.or(
     ParseObject(EventEntity.className),
     listQueries,
   );

Until then, everything is fine. Of these events I only want the ones that are on the date of the following excerpt

   final QueryBuilder<ParseObject> queryByDate =
       QueryBuilder<ParseObject>(ParseObject(EventEntity.className));
   final start = DateTime(2023, 06, 25);
   final end = DateTime(2023, 06, 27);

   queryByDate.whereGreaterThanOrEqualsTo(
       EventEntity.day, DateTime(start.year, start.month, start.day));
   queryByDate.whereLessThanOrEqualTo(
       EventEntity.day, DateTime(end.year, end.month, end.day, 23, 59));

I think the following snippet would give me the and between them. That is, events by date and by user.

   QueryBuilder<ParseObject> mainQuery2 =
       QueryBuilder.and(ParseObject(EventEntity.className), [queryByDate, eventsByUser]);

But it doesn't return anything.

The queryByDate query returns the events: ZVf7WTd6cM qAvT71CMAL

The query eventsByUser returns the events: HMsggKqGmz P5F1D6dsJz ZVf7WTd6cM rFHpMtVkaE

See that what I want is precisely the ZVf7WTd6cM event that belongs to the customer service on the specified date.

Steps to reproduce

any pure query and QueryBuilder.and and QueryBuilder.or

Actual Outcome

Expected Outcome

Environment

Parse Flutter SDK

Server

Logs

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

mtrezza commented 1 year ago

@catalunha Is this a suspected SDK issue or are you asking for code support?

catalunha commented 1 year ago

Sorry. What would it be: Is this a suspected SDK issue

catalunha commented 1 year ago

I already changed the Parse Version in B4A. I already changed the parse_server_sdk in the pubspec and nothing works for this query.