Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiveQuery not triggering event callbacks when using query.containedIn. #2088

Closed
wookiem opened this issue Jun 17, 2016 · 11 comments
Closed

LiveQuery not triggering event callbacks when using query.containedIn. #2088

wookiem opened this issue Jun 17, 2016 · 11 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@wookiem
Copy link

wookiem commented Jun 17, 2016

LiveQuery not triggering event callbacks when using query.containedIn.

Steps to reproduce

A) Parse database contains following classes:

Proposal = [
    {
        objectId: gLbeSQLSkf,
        itemId: 2iyjvsN1Pi,
        retailPrice: 31
    },
    {
        objectId: EoJRfZcLth,
        itemId: Q8t0uSnvKn,
        Price: 4
    }
]

Items = [
    {itemId: 2iyjvsN2Pi},
    {itemId: Q8t0uSnvKn}
]

B) JavaScript nextProps variable contains following

nextProps.items = [
    {itemId: 2iyjvsN2Pi},
    {itemId: Q8t0uSnvKn}
]

C) Code for Query subscription

componentWillReceiveProps( nextProps ) {
    {
        let proposalQuery = new Parse.Query('Proposal');
        let items = nextProps.items;
        let itemPointers = items.map((item) => {
            let ItemPointer = new Parse.Object("Item");
            ItemPointer.id = item.itemId;
            return ItemPointer;
        }); 
        proposalQuery.containedIn('itemId', itemPointers);
        var proposalSubscription = proposalQuery.subscribe();

        proposalSubscription.on('create', (proposal) => {
            console.log('created new proposal');
        });

        proposalSubscription.on('update', (proposal) => {
            console.log('updated existing proposal');
        });     
    }

E) Change retailPrice in Parse Dashboard from 31 to 30

F) Output from Parse Server (verbose)

verbose: PUT /parse/classes/Proposal/gLbeSQLSkf { host: 'localhost:1337',
  connection: 'keep-alive',
  'content-length': '205',
  origin: 'http://0.0.0.0:4040',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36',
  'content-type': 'text/plain',
  accept: '*/*',
  referer: 'http://0.0.0.0:4040/apps/idpractice/browser/Proposal',
  'accept-encoding': 'gzip, deflate',
  'accept-language': 'en-US,en;q=0.8' } {
  "retailPrice": 30
}
verbose: {
  "response": {
    "updatedAt": "2016-06-17T13:03:20.119Z"
  }
}

G. Subscription 'update' Callback doesn't trigger

H. Remove query.containedIn from query

componentWillReceiveProps( nextProps ) {
    {
        let proposalQuery = new Parse.Query('Proposal');
        var proposalSubscription = proposalQuery.subscribe();

        proposalSubscription.on('create', (proposal) => {
            console.log('added mfr model#: ', proposal.get('manufacturerModelNumber'));
        });

        proposalSubscription.on('update', (proposal) => {
            console.log('updated mfr model#: ', proposal.get('manufacturerModelNumber'));
        });     
    }

I) Change retailPrice in Parse Dashboard from 30 back to 31

J) Output from Parse Server (verbose)

verbose: PUT /parse/classes/Proposal/gLbeSQLSkf { host: 'localhost:1337',
  connection: 'keep-alive',
  'content-length': '205',
  origin: 'http://0.0.0.0:4040',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36',
  'content-type': 'text/plain',
  accept: '*/*',
  referer: 'http://0.0.0.0:4040/apps/idpractice/browser/Proposal',
  'accept-encoding': 'gzip, deflate',
  'accept-language': 'en-US,en;q=0.8' } {
  "retailPrice": 31
}
verbose: {
  "response": {
    "updatedAt": "2016-06-17T13:23:43.386Z"
  }
}

K. Subscription 'update' Callback triggers (note: no output from parse server in verbose mode)

L. Demonstrate that query.containedIn works with query.find

componentWillReceiveProps( nextProps ) {
    {
        let proposalQuery = new Parse.Query('Proposal');
        let items = nextProps.items;
        let itemPointers = items.map((item) => {
            let ItemPointer = new Parse.Object("Item");
            ItemPointer.id = item.itemId;
            return ItemPointer;
        }); 
        proposalQuery.containedIn('itemId', itemPointers);
        proposalQuery.find({
            success: function (proposals) {
                console.log('number of proposal = ' + proposals.length)
            },
            error: function(error) {
                console.log('error: ', error);
            }
        });
    }

M. Console outputs "number of proposals = 2"

Expected Results

See above

Actual Outcome

See above

Environment Setup

  • Server
    • parse-server version: 2.2.12
    • Operating System: react-native: 0.26.1 running on iOS 9.3 simulator
    • Hardware: iOS 9.3 simulator
    • Localhost or remote server? Localhost
  • Database
    • MongoDB version: Running mLab "SandBox" tier
    • Localhost or remote server? mLab
  • Client
    • Parse JS API: 1.8.5

Logs/Trace

See above

@hramos hramos added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 6, 2016
@hramos
Copy link
Contributor

hramos commented Sep 6, 2016

Can you take a look and see if this still happens on Parse Server 2.2.18?

@wookiem
Copy link
Author

wookiem commented Sep 13, 2016

I should be able to test this out over the weekend. Stay tuned @hramos.

@wookiem
Copy link
Author

wookiem commented Sep 17, 2016

@hramos I've repeated the same testing after upgrading to parse-server to 2.2.18. Still the same outcome as documented before (i.e, proposal 'create' and 'proposal' updates are not triggering subscription events when using query.containedIn).

@trungtin
Copy link

Any update on this? I have the same problem.

@fmendoza
Copy link

Updates? Same here on latest parse server and parse js client

@matheusfrozzi
Copy link

+1

@flovilmart
Copy link
Contributor

@matheusfrozzi did you try on the latest version of parse-server as there's been some work in that area: https://github.com/parse-community/parse-server/releases/tag/2.6.3

@flovilmart
Copy link
Contributor

Closing as released part of 2.6.3, (#4231)

@stewones
Copy link
Contributor

stewones commented Oct 21, 2019

not working on 3.9.0. though notContainedIn works

@stewones
Copy link
Contributor

bump. is there any regression, it doesn't work on latest

@stewones
Copy link
Contributor

alright sent a PR #8128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

7 participants