Skip to content

withinKilometers withinMiles withinRadians not working with Live Query #7480

Closed
@PolSpock

Description

@PolSpock

New Issue Checklist

Issue Description

I want to retrieve object only in a specific radius of the user current Position.
I use Live Query to get when object enter, update, leave theses conditions in real time.

However when i write a query with withinKilometers / withinMiles / withinRadians the Live Query never triggered when the Object has his GeoPoint enter / update / leave the specific radius.

Steps to reproduce

  1. Setup a parse-server with Live Query
  2. Create a class with a GeoPoint column (in my example, my column is "location")
  3. Create a client, i tried on Parse Flutter SDK and Parse Javascript SDK
  4. Connect the client, make a Parse Query with a subscription based on withinKilometers / withinMiles / withinRadians conditions
    My javascript example :
<html>
<head>
    <meta charset="utf-8">
    <title>Test</title>
    <script src="https://unpkg.com/parse/dist/parse.js"></script>
    <script>
        main();
        async function main() {
            Parse.initialize("xxxxxxxxxxxxx");
            Parse.serverURL = 'http://192.168.X.X:1337/parse'

            var query = new Parse.Query('TestObject');
            query.withinKilometers("location", new Parse.GeoPoint({latitude: 45, longitude: 2}), 1, false);
            var subscription = await query.subscribe();

            subscription.on('open', () => {
                console.log('subscription opened');
            });

            subscription.on('update', (object) => {
                console.log(object);
                console.log('object updated');
            });

            subscription.on('enter', (object) => {
                console.log(object);
                console.log('enter updated');
            });

            subscription.on('leave', (object) => {
                console.log(object);

                console.log('object left');
            });

            subscription.on('delete', (object) => {
                console.log(object);

                console.log('object deleted');
            });

            subscription.on('close', () => {
                console.log('subscription closed');
            });
        }
    </script>
</head>
<body>
    <p>Test</p>
</body>
</html>

Actual Outcome

My Live Query subscription is never triggered when the GeoPoint respect the subscription conditions.

If i replace the .subscription() by .find() the query worked fine, but this is not i want cause i need Live Query

Expected Outcome

I expect to get my TestObject when his location is update and still respect my subscription condition.

In my example : a TestObject with "location" Parse.GeoPoint({latitude: 45, longitude: 2}) must be return to client because the client have the same position and the withinKilometers is respected.
(see my example line query.withinKilometers("location", new Parse.GeoPoint({latitude: 45, longitude: 2}), 1, false);)

Failing Test Case / Pull Request

Environment

Server

  • Parse Server version: 4.5.0
  • Operating system: Windows 10.0.19043
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 4.4.4
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Local

Clients

  • SDK JavaScript version: 3.3.0
  • SDK Flutter version: 3.1.0

Logs

No log

Regards !

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions