loopbackio / loopback-datasource-juggler

Connect Loopback to various Data Sources
http://www.loopback.io
Other
277 stars 364 forks source link

Simple filter now broken in v3.7.0+ #1381

Closed devpascoe closed 7 years ago

devpascoe commented 7 years ago

I have a url...pretty simple and been working fine up until the 3.7.0 update the url is a simple /items?filter[where][columnname]=20

Get the following error in console...

/loopback-datasource-juggler/lib/scope.js:119
          var idsB = qWhere[idKey].inq ? qWhere[idKey].inq : [qWhere[idKey]];
                                  ^

TypeError: Cannot read property 'inq' of undefined
    at smartMerge (/loopback-datasource-juggler/lib/scope.js:119:35)

If i revert to version 3.6.1 things work perfectly again. I'm running against a postgres db. Anyone come across this?

dhmlau commented 7 years ago

@devpascoe , I just tried to do a filter. It seems to be working for me. I'm using v3.9.0. Could you please update to see if you still encounter this issue? Thanks.

robtassl commented 7 years ago

Im having this issue as well. It seems to only effect my models with relations.

dhmlau commented 7 years ago

I see. I was just using a very simple model. Mind to share your models or application? https://github.com/strongloop/loopback/wiki/Reporting-issues#bug-report.

matteo-harpoon commented 7 years ago

@dhmlau here's the full log. I tried with v3.7.0 and v3.9.0, v3.6.1 works fine.

     Uncaught TypeError: Cannot read property 'inq' of undefined
      at smartMerge (node_modules/loopback-datasource-juggler/lib/scope.js:119:35)
      at buildWhere (node_modules/loopback-datasource-juggler/lib/scope.js:129:29)
      at node_modules/loopback-datasource-juggler/lib/scope.js:133:32
      at node_modules/loopback-datasource-juggler/lib/dao.js:2093:9
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1012:9
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:359:16
      at iteratorCallback (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:935:13)
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:843:16
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1009:13
      at buildResult (node_modules/loopback-datasource-juggler/lib/dao.js:2059:11)
      at node_modules/loopback-datasource-juggler/lib/dao.js:2073:13
      at doNotify (node_modules/loopback-datasource-juggler/lib/observer.js:99:49)
      at doNotify (node_modules/loopback-datasource-juggler/lib/observer.js:99:49)
      at doNotify (node_modules/loopback-datasource-juggler/lib/observer.js:99:49)
      at doNotify (node_modules/loopback-datasource-juggler/lib/observer.js:99:49)
      at Function.ObserverMixin._notifyBaseObservers (node_modules/loopback-datasource-juggler/lib/observer.js:122:5)
      at Function.ObserverMixin.notifyObserversOf (node_modules/loopback-datasource-juggler/lib/observer.js:97:8)
      at Function.ObserverMixin._notifyBaseObservers (node_modules/loopback-datasource-juggler/lib/observer.js:120:15)
      at Function.ObserverMixin.notifyObserversOf (node_modules/loopback-datasource-juggler/lib/observer.js:97:8)
      at Function.ObserverMixin._notifyBaseObservers (node_modules/loopback-datasource-juggler/lib/observer.js:120:15)
      at Function.ObserverMixin.notifyObserversOf (node_modules/loopback-datasource-juggler/lib/observer.js:97:8)
      at Function.ObserverMixin._notifyBaseObservers (node_modules/loopback-datasource-juggler/lib/observer.js:120:15)
      at Function.ObserverMixin.notifyObserversOf (node_modules/loopback-datasource-juggler/lib/observer.js:97:8)
      at withNotify (node_modules/loopback-datasource-juggler/lib/dao.js:2071:17)
      at node_modules/loopback-datasource-juggler/lib/dao.js:2012:11
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1007:9
      at eachOfArrayLike (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:940:9)
      at eachOf (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:990:5)
      at _asyncMap (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1005:5)
      at Object.map (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:995:16)
      at allCb (node_modules/loopback-datasource-juggler/lib/dao.js:2007:13)
      at node_modules/loopback-datasource-juggler/lib/include.js:186:11
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:359:16
      at iteratorCallback (node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:935:13)
      at node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:843:16
      at node_modules/loopback-datasource-juggler/lib/include.js:104:11
      at _combinedTickCallback (internal/process/next_tick.js:67:7)
      at process._tickCallback (internal/process/next_tick.js:98:9)

I'm using loopback@v3.8.0 and this is my datasources.test.json .

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "tweak-db": {
    "name": "tweak-db",
    "connector": "memory",
    "file": "tweak-db.json"
  },
  "transient": {
    "name": "transient",
    "connector": "transient"
  },
  "mandrill": {
    "connector": "lb-connector-mandrill",
    "apikey": "...",
    "async": true
  }
}
htmlauthor commented 7 years ago

I am facing same issue. Was working fine with 3.6.1, now broke after upgrading to 3.9.1.

2017-06-02T13:16:38.164Z pid:18584 worker:15 /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/scope.js:119 2017-06-02T13:16:38.164Z pid:18584 worker:15 var idsB = qWhere[idKey].inq ? qWhere[idKey].inq : [qWhere[idKey]]; 2017-06-02T13:16:38.164Z pid:18584 worker:15 ^ 2017-06-02T13:16:38.165Z pid:18584 worker:15 TypeError: Cannot read property 'inq' of undefined 2017-06-02T13:16:38.165Z pid:18584 worker:15 at smartMerge (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/scope.js:119:35) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at buildWhere (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/scope.js:129:29) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/scope.js:133:32 2017-06-02T13:16:38.165Z pid:18584 worker:15 at Object.forward (/usr/local/lib/node_modules/strong-pm/node_modules/strong-agent/lib/proxy.js:92:23) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at eval (eval at wrap (/usr/local/lib/node_modules/strong-pm/node_modules/strong-agent/lib/proxy.js:222:20), :3:21) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/dao.js:2093:9 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1012:9 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:359:16 2017-06-02T13:16:38.165Z pid:18584 worker:15 at iteratorCallback (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:935:13) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:843:16 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/node_modules/async/dist/async.js:1009:13 2017-06-02T13:16:38.165Z pid:18584 worker:15 at buildResult (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/dao.js:2059:11) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at /var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/dao.js:2073:13 2017-06-02T13:16:38.165Z pid:18584 worker:15 at doNotify (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/observer.js:99:49) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at doNotify (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/observer.js:99:49) 2017-06-02T13:16:38.165Z pid:18584 worker:15 at doNotify (/var/lib/strong-pm/svc/1/work/b40de3c00a4ea5c662ab21a362ab1761cbc6be9b.1496409200594/node_modules/loopback-datasource-juggler/lib/observer.js:99:49)

I am using MySQL connector and couple of tables with relationship between them.

dhmlau commented 7 years ago

Hi @Setogit, could you pls take a look? It might be related to your recent changes in scope.js. Thanks!

raymondfeng commented 7 years ago

https://github.com/strongloop/loopback-datasource-juggler/commit/c07f46000d1c3888701c3e1fc5f956cb373db5a5

Setogit commented 7 years ago

@dhmlau PTAL https://github.com/strongloop/loopback-datasource-juggler/pull/1401

dhmlau commented 7 years ago

Closing this issue as PR #1401 has been landed.

jonathan-casarrubias commented 7 years ago

@raymondfeng @dhmlau I don't think this is fixed..

I have tried with version 3.9.1 and the issue remains.

This is happening to me when I have a HasManyThrough relationship

Account <- AccountProject -> Projects.

When I call for:

[GET] accounts/:id/projects

Note that without filter works fine, but when I add a filter like:

{
  "where": {
    "name": { "like": ".*test.*", "options": "i" }
  }
}

I do get the TypeError: Cannot read property 'inq' of undefined error. When I downgraded to 3.6.1 then it started to work, after I unsuccessfully tried 3.6.9, 3.7.0 and 3.9.1.

I think you should re-open this issue, from my perspective is really really critical.

Regards Jon

dhmlau commented 7 years ago

@Setogit , Could you please PTAL? Thanks.

Setogit commented 7 years ago

The commit log says the change (hopefully a fix) has been released as 3.9.2.

dhmlau commented 7 years ago

@jonathan-casarrubias could you please verify?

jonathan-casarrubias commented 7 years ago

@dhmlau I have just verified and it seems it's fixed now... 🥇

dhmlau commented 7 years ago

That's great. I'm closing it now. Thanks!