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

Error at startup when migrating from 0.10.10 to 0.10.50 #90

Closed
pemontabrun opened this issue May 4, 2015 · 11 comments
Closed

Error at startup when migrating from 0.10.10 to 0.10.50 #90

pemontabrun opened this issue May 4, 2015 · 11 comments
Labels

Comments

@pemontabrun
Copy link

Hi,

I've recently updated sails-orientdb from 0.10.10 with orientDB 1.7.10 to 0.10.50 with orientDB 2.0.8 and this error shows up when lifting sails:

  this.waterlineSchema = _.values(collections)[0].waterline.schema;
                                                 ^
TypeError: Cannot read property 'waterline' of undefined
    at new Connection (/Path/To/Project/node_modules/sails-orientdb/lib/connection.js:41:50)
    at Object.module.exports.adapter.registerConnection (/Path/To/Project/node_modules/sails-orientdb/lib/adapter.js:167:42)
    at /Path/To/Project/node_modules/sails/node_modules/waterline/lib/waterline.js:203:29
    at /Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:125:13
    at Array.forEach (native)
    at _each (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:46:24)
    at Object.async.each (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:124:9)
    at Array.async.auto.registerConnections (/Path/To/Project/node_modules/sails/node_modules/waterline/lib/waterline.js:176:13)
    at /Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:487:38
    at Array.forEach (native)
    at _each (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:46:24)
    at Object.async.auto (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:458:9)
    at Waterline.initialize (/Path/To/Project/node_modules/sails/node_modules/waterline/lib/waterline.js:121:9)
    at buildORM (/Path/To/Project/node_modules/sails/lib/hooks/orm/build-orm.js:52:15)
    at Array.async.auto.instantiatedCollections (/Path/To/Project/node_modules/sails/lib/hooks/orm/index.js:203:11)
    at listener (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:493:46)
    at /Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:444:17
    at Array.forEach (native)
    at _each (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:46:24)
    at Immediate.taskComplete (/Path/To/Project/node_modules/sails/node_modules/async/lib/async.js:443:13)
    at processImmediate [as _immediateCallback] (timers.js:358:17)

I have tried both with sails 0.10.x and 0.11.x but the error still remains. Is there something to modify in the config files when migrating from older version?

Thanks,

PE

@dmarcelino
Copy link
Member

Hey @pemontabrun, that's a big jump. v0.10.10 used vjsrinath codebase while v0.10.50 uses the (previously named) waterline-orientdb which is pretty much a re-write.

Do you have any model definitions? Can you share your config?

@pemontabrun
Copy link
Author

Yes I haven't upgraded since my first PoC so it's been months now. Here is one model:

var Item = {
    schema: true,
    tableName: 'Item',
    attributes: {
        id: {
          type: 'string',
          primaryKey: true,
          columnName: '@rid'
        },
        prop1: {
          type: 'string',
          unique: true,
          required: true
        },
        prop2 : {
          type: 'string',
          required: true,
          index: 'fulltext'
        },
        toPublicJson : function(){
          return {
            prop1: this.prop1,
            prop2: this.prop2
          };
        }
    }
};

module.exports = Item;

@dmarcelino
Copy link
Member

I don't see anything wrong... how does your config looks like?

@pemontabrun
Copy link
Author

Here is what my connection file looks like:

localOrientDB: {
        adapter: 'sails-orientdb',
        database: {
          name: 'db1'
        },
        username: "userdb",
        password: "pass"
    },

Do you need some other config files?

@dmarcelino
Copy link
Member

Try:

localOrientDB: {
        adapter: 'sails-orientdb',
        database: 'db1',
        username: "userdb",
        password: "pass"
    },

Here's a more complete example: https://github.com/appscot/sails-orientdb#basic-example

@dmarcelino
Copy link
Member

Any luck?

@dmarcelino
Copy link
Member

Please re-open if the answer didn't address the issue.

@pemontabrun
Copy link
Author

Sorry for the delay, I was basically afk these last 2 weeks.
I have run some tests on a fresh install and I found out that having more than one orientdb connection described in the connection file triggers the error (with the latest version pulled from github). It didn't trigger the error before I upgraded from versions before 10.10. This happens even if your env or prod config files only refers to one connection.
For now, as I use a different config for prod and dev I just need to comment it out but it could be a serious problem for those who need to connect to several databases.

@dmarcelino dmarcelino reopened this May 17, 2015
@dmarcelino dmarcelino added bug and removed question labels May 17, 2015
@dmarcelino
Copy link
Member

@pemontabrun, can you please share your connection file?

@pemontabrun
Copy link
Author

Here it is:

module.exports.connections = {

  devOrientDB: {
    adapter: 'sails-orientdb',
    host: 'localhost',
    port: 2424,
    database: 'bdd1',
    username: "usernameDev",
    password: "blabla"
  },

  prodOrientDB: {
    adapter: 'sails-orientdb',
    host: 'localhost',
    port: 2424,
    database: 'bdd2',
    username: "usernameProd",
    password: "blabla"
  }

};

With this config file, Sails can't lift correctly and throws the error described in my first message.

dmarcelino added a commit that referenced this issue May 17, 2015
@dmarcelino
Copy link
Member

I think I've figured the issue, I'm guessing one of your connections has no associated model definitions, right?

I managed to reproduce the error you're getting in f4e6277 and fixed it in 039f5b6 while outputting a warning message:

sails-orientdb:connection:warn  This connection has no associated collections, the CRUD methods won't work! +0ms

Since without collections loaded for a given connection you won't be able to do much with it.

You can try this fix by installing the master branch from github:

npm i appscot/sails-orientdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants