{"action":"opened","issue":{"url":"https://api.github.com/repos/hiddentao/squel/issues/229","repository_url":"https://api.github.com/repos/hiddentao/squel","labels_url":"https://api.github.com/repos/hiddentao/squel/issues/229/labels{/name}","comments_url":"https://api.github.com/repos/hiddentao/squel/issues/229/comments","events_url":"https://api.github.com/repos/hiddentao/squel/issues/229/events","html_url":"https://github.com/hiddentao/squel/issues/229","id":149548448,"number":229,"title":"Two instances of sequel will not handle subqueries correctly","user":{"login":"rooftopsparrow","id":853349,"avatar_url":"https://avatars.githubusercontent.com/u/853349?v=3","gravatar_id":"","url":"https://api.github.com/users/rooftopsparrow","html_url":"https://github.com/rooftopsparrow","followers_url":"https://api.github.com/users/rooftopsparrow/followers","following_url":"https://api.github.com/users/rooftopsparrow/following{/other_user}","gists_url":"https://api.github.com/users/rooftopsparrow/gists{/gist_id}","starred_url":"https://api.github.com/users/rooftopsparrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rooftopsparrow/subscriptions","organizations_url":"https://api.github.com/users/rooftopsparrow/orgs","repos_url":"https://api.github.com/users/rooftopsparrow/repos","events_url":"https://api.github.com/users/rooftopsparrow/events{/privacy}","received_events_url":"https://api.github.com/users/rooftopsparrow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-19T18:46:54Z","updated_at":"2016-04-19T18:46:54Z","closed_at":null,"body":"I wrote a little test script to demonstrate the issue ( bash environment assumed ).\r\n\r\n```bash\r\nmkdir test\r\ncd test\r\nmkdir node_modules\r\ncd node_modules\r\nmkdir test-lib\r\ncd test-lib\r\ncat <<EOF > index.js\r\nvar squel = require('squel')\r\nmodule.exports = function testQuery() {\r\n  return squel.select().from('things').where('a = ?', 1)\r\n}\r\nEOF\r\nnpm init -y\r\nnpm install squel -S\r\ncd ../..\r\ncat <<EOF > index.js\r\nvar testLib = require('test-lib')\r\nvar squel = require('squel')\r\nvar q = testLib()\r\nq.where('b in ?', squel.select().field('b').from('otherthings'))\r\nconsole.log('result => ', q.toString())\r\nEOF\r\nnpm init -y\r\nnpm install squel -S\r\nnode index.js\r\n# result =>  SELECT * FROM things WHERE (a = 1) AND (b in 'SELECT b FROM otherthings')\r\n```\r\n\r\nThe above result shows the subquery is a string instead of an actual subquery. Once we eliminate the duplicate library it works:\r\n\r\n```bash\r\nnpm dedupe\r\nnode index.js\r\nresult =>  SELECT * FROM things WHERE (a = 1) AND (b in (SELECT b FROM otherthings))\r\n```\r\n\r\nWhat is concerning about this is when there are different versions of the same library, duplicate libraries are expected in the npm tree and the same issue will happen.\r\n\r\nLet me know if I can assist in figuring this out or if what I've provided here is unclear. Thanks!"}}