loopback-connector-elastic-search icon indicating copy to clipboard operation
loopback-connector-elastic-search copied to clipboard

Test for findByIds fails

Open pulkitsinghal opened this issue 10 years ago • 3 comments

I've temporarily commented out the part of the test which fails.

The original test case was available at: https://github.com/strongloop/loopback-datasource-juggler/blob/master/test/basic-querying.test.js

I simply copied and repurposed it here: https://github.com/strongloop-community/loopback-connector-elastic-search/blob/master/test/02.basic-querying.test.js

In order to reproduce the problem:

  1. un-comment the following lines:
names.should.eql( // NOTE: order doesn't add up, is 2.ii.iii broken?
    [createdUsers[2].name, createdUsers[1].name, createdUsers[0].name]);
  1. comment-out the following lines:

    names.should.include(createdUsers[2].name);
    names.should.include(createdUsers[1].name);
    names.should.include(createdUsers[0].name);
    

pulkitsinghal avatar Apr 02 '15 15:04 pulkitsinghal

After you follow the steps above to reproduce the problem: You will see a failure like the following in logs when you run DEBUG=loopback:connector:* mocha:

loopback:connector:elasticsearch ESConnector.prototype.all +0ms model User result [
  {
    "seq": 1,
    "name": "a",
    "vip": true
  },
  {
    "seq": 2,
    "name": "b"
  },
  {
    "seq": 3,
    "name": "c"
  }
]
Possibly unhandled AssertionError: expected [ 'a', 'b', 'c' ] to deeply equal [ 'c', 'b', 'a' ]
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/test/02.basic-querying.test.js:160:38
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/node_modules/loopback-datasource-juggler/lib/dao.js:721:5
    at allCb (/Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/node_modules/loopback-datasource-juggler/lib/dao.js:1210:7)
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/lib/esConnector.js:705:17
    ...

pulkitsinghal avatar Apr 02 '15 15:04 pulkitsinghal

@raymondfeng - Is the core code unable to sort when the id is represented by something other than id? Like seq in this example? If so, would you mind opening an issues in the appropriate repository and leaving a reference to it here as well.

pulkitsinghal avatar Apr 02 '15 15:04 pulkitsinghal

  1. find code that tries to add sort order and tell it not to do so because findByIds isn't meant to work like that
  2. can get clues from how mongo connector tracks the calling method name to accomplish the same thing

pulkitsinghal avatar Jul 30 '16 04:07 pulkitsinghal