{"action":"opened","issue":{"url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/246","repository_url":"https://api.github.com/repos/balderdashy/sails-postgresql","labels_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/246/comments","events_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/246/events","html_url":"https://github.com/balderdashy/sails-postgresql/issues/246","id":155406945,"number":246,"title":"Encountered an unexpected error / syntax error at or near \"SELEC\"","user":{"login":"reggi","id":296798,"avatar_url":"https://avatars.githubusercontent.com/u/296798?v=3","gravatar_id":"","url":"https://api.github.com/users/reggi","html_url":"https://github.com/reggi","followers_url":"https://api.github.com/users/reggi/followers","following_url":"https://api.github.com/users/reggi/following{/other_user}","gists_url":"https://api.github.com/users/reggi/gists{/gist_id}","starred_url":"https://api.github.com/users/reggi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reggi/subscriptions","organizations_url":"https://api.github.com/users/reggi/orgs","repos_url":"https://api.github.com/users/reggi/repos","events_url":"https://api.github.com/users/reggi/events{/privacy}","received_events_url":"https://api.github.com/users/reggi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-18T03:01:39Z","updated_at":"2016-05-18T03:01:39Z","closed_at":null,"body":"Example script fails on second run.\r\n\r\n```\r\nThomass-MBP-2:waterline-test thomas$ node working.js \r\n[ { pets: \r\n     [ { breed: 'beagle',\r\n         type: 'dog',\r\n         name: 'Astro',\r\n         owner: 1,\r\n         id: 1,\r\n         createdAt: '2016-05-18T02:58:48.000Z',\r\n         updatedAt: '2016-05-18T02:58:48.000Z' } ],\r\n    firstName: 'Neil',\r\n    lastName: 'Armstrong',\r\n    id: 1,\r\n    createdAt: '2016-05-18T02:58:48.000Z',\r\n    updatedAt: '2016-05-18T02:58:48.000Z' } ]\r\n^C\r\nThomass-MBP-2:waterline-test thomas$ node working.js \r\nError (E_UNKNOWN) :: Encountered an unexpected error\r\nerror: syntax error at or near \"SELEC\"\r\n    at Connection.parseE (/Users/thomas/Desktop/waterline-test/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)\r\n    at Connection.parseMessage (/Users/thomas/Desktop/waterline-test/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)\r\n    at Socket.<anonymous> (/Users/thomas/Desktop/waterline-test/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)\r\n    at emitOne (events.js:90:13)\r\n    at Socket.emit (events.js:182:7)\r\n    at readableAddChunk (_stream_readable.js:153:18)\r\n    at Socket.Readable.push (_stream_readable.js:111:10)\r\n    at TCP.onread (net.js:531:20)\r\n\r\nDetails:  error: syntax error at or near \"SELEC\"\r\n```\r\n\r\nCode\r\n\r\n```js\r\n/**\r\n * A really simple Waterline application.\r\n *\r\n * @license MIT\r\n */\r\n\r\nvar Waterline = require('waterline');\r\nvar sailsPostgresAdapter = require('sails-postgresql');\r\n\r\n// Create the waterline instance.\r\nvar waterline = new Waterline();\r\n\r\n// Create a specification for a User model.\r\nvar userCollection = Waterline.Collection.extend({\r\n\tidentity: 'user',\r\n\tconnection: 'default',\r\n\tattributes: {\r\n\t\tfirstName: 'string',\r\n\t\tlastName: 'string',\r\n\r\n\t\t// Add a reference to Pets\r\n\t\tpets: {\r\n\t\t\tcollection: 'pet',\r\n\t\t\tvia: 'owner'\r\n\t\t}\r\n\t}\r\n});\r\n\r\n// Create a specification for a Pet model.\r\nvar petCollection = Waterline.Collection.extend({\r\n\tidentity: 'pet',\r\n\tconnection: 'default',\r\n\tattributes: {\r\n\t\tbreed: 'string',\r\n\t\ttype: 'string',\r\n\t\tname: 'string',\r\n\r\n\t\t// Add a reference to User\r\n\t\towner: {\r\n\t\t\tmodel: 'user'\r\n\t\t}\r\n\t}\r\n});\r\n\r\n// Add the models to the waterline instance.\r\nwaterline.loadCollection(userCollection);\r\nwaterline.loadCollection(petCollection);\r\n\r\n// Set up the storage configuration for waterline.\r\nvar config = {\r\n\tadapters: {\r\n    'postgres': sailsPostgresAdapter,\r\n\t},\r\n\tconnections: {\r\n    default: {\r\n      adapter: 'postgres',\r\n      database: 'database',\r\n      host: 'localhost',\r\n      user: 'thomas',\r\n      port: 5432,\r\n      poolSize: 10,\r\n      ssl: false\r\n    }\r\n\t}\r\n}\r\n// Initialise the waterline instance.\r\nwaterline.initialize(config, function (err, ontology) {\r\n\tif (err) {\r\n\t\treturn console.error(err);\r\n\t}\r\n\r\n\t// Tease out fully initialised models.\r\n\tvar User = ontology.collections.user;\r\n\tvar Pet = ontology.collections.pet;\r\n\r\n\t// First we create a user.\r\n\tUser.create({\r\n\t\t\tfirstName: 'Neil',\r\n\t\t\tlastName: 'Armstrong'\r\n\t\t})\r\n\t\t.then(function (user) {\r\n\t\t\t// Then we can create a pet for the user.\r\n\t\t\t// Note that waterline automatically adds the `id` primary key to the model.\r\n\t\t\tPet.create({\r\n\t\t\t\tbreed: 'beagle',\r\n\t\t\t\ttype: 'dog',\r\n\t\t\t\tname: 'Astro',\r\n\t\t\t\towner: user.id\r\n\t\t\t})\r\n\t\t\t\t.then(function (pet) {\r\n\t\t\t\t\t// Then we can associate the pet with the user.\r\n\t\t\t\t\tuser.pets = [pet];\r\n\r\n\t\t\t\t\t// And save the user.\r\n\t\t\t\t\treturn user.save();\r\n\t\t\t\t})\r\n\t\t\t\t.then(function () {\r\n\t\t\t\t\t// And now we want to get the new user back,\r\n\t\t\t\t\t// and populate the pets the user might own.\r\n\t\t\t\t\treturn User.find()\r\n\t\t\t\t\t\t.populate('pets');\r\n\t\t\t\t})\r\n\t\t\t\t.then(console.log)\r\n\t\t\t\t.catch(console.error);\r\n\t\t});\r\n});\r\n```"}}