appscot / sails-orientdb

OrientDB adapter for Waterline / Sails.js ORM
MIT License
25 stars 23 forks source link

Found class name null or empty #116

Closed tommykennedy closed 9 years ago

tommykennedy commented 9 years ago

Hi Dario,

I am running the following code below on sails-orientdb v0.10.55. I get the error below. I have played around with the answer variable and the length of the object name seems to cause it. The Answer parameter is of type JSON.

OrientDB Server v2.1-rc4 Oriento 1.1.3

Any ideas?

Tom

    var answer = {binaryanswer:'yes'};
    console.log(answer);

    Answer.create({
        question: req.param('id'),
        Answer: answer
    }, function (err, quest) {
        console.log(err);
        if (err) return res.send(500, err);

        console.log("This was ok");
    });

Error (E_UNKNOWN) :: Encountered an unexpected error

OrientDB.RequestError: Found class name null or empty

at Operation.parseError (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/protocol28/operation.js:832:13)

at Operation.consume (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/protocol28/operation.js:422:35)

at Connection.process (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/connection.js:360:17)

at Connection.handleSocketData (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/connection.js:279:17)

at Socket.emit (events.js:107:17)

at readableAddChunk (_stream_readable.js:163:16)

at Socket.Readable.push (_stream_readable.js:126:10)

at TCP.onread (net.js:538:20)

From previous event:

at Connection._sendOp (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/connection.js:79:10)

at Connection.send (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/connection.js:63:17)

at BinaryTransport.send (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/transport/binary/index.js:191:43)

at Server.send (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/server/index.js:112:25)

at Db.<anonymous> (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/index.js:152:24)

at processImmediate [as _immediateCallback] (timers.js:358:17)

From previous event:

at Db.send (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/index.js:144:4)

at Db.exec (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/index.js:247:22)

at Db.query (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/index.js:279:15)

at module.exports.Statement.extend.exec (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/query.js:108:20)

at module.exports.Statement.extend.all (/Users/thomaskenedy/sandbox/LegoSix/node_modules/oriento/lib/db/query.js:70:17)

at update (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/collection/document.js:201:6)

at Connection.update (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/connection.js:381:32)

at Object.module.exports.adapter.update (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/adapter.js:309:38)

at module.exports.update (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:239:13)

at bound.updateRecords (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:197:16)

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:52:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:254:17

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:251:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:615:34

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at bound.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44)

at fn (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:79:10)

at iterate (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:149:13)

at Object.async.eachSeries (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:165:9)

at Object.runner.beforeUpdate (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:82:9)

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:165:17

From previous event:

at insert (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/collection/document.js:149:6)

at Connection.create (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/connection.js:373:32)

at Object.module.exports.adapter.create (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/adapter.js:300:38)

at module.exports.create (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:85:13)

at bound.createValues (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:213:16)

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:74:20

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:254:17

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:251:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:615:34

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at bound.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44)

at fn (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:41:10)

at iterate (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:149:13)

at Object.async.eachSeries (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:165:9)

at Object.runner.beforeCreate (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:44:9)

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:179:17

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:610:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:249:17

at iterate (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:149:13)

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:160:25

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:251:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:615:34

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:71:7

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:254:17

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:251:21

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:615:34

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:65:11

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:157:25

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:59:13

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44

at runner (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:57:11)

at iterate (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:149:13)

at Object.async.eachSeries (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:165:9)

at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/validate.js:63:15

at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:610:21

From previous event:

at find (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/collection/document.js:114:6)

at Connection.find (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/connection.js:344:32)

at Object.module.exports.adapter.find (/Users/thomaskenedy/sandbox/LegoSix/node_modules/sails-orientdb/lib/adapter.js:292:38)

at module.exports.find (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:121:13)

at module.exports.findOne (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:161:10)

at _runOperation (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:400:29)

at run (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:69:8)

at bound.module.exports.findOne (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:66:16)

at bound [as findOne] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)

at /Users/thomaskenedy/sandbox/LegoSix/api/services/passport.js:403:10

at pass (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/authenticator.js:353:9)

at Authenticator.deserializeUser (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/authenticator.js:358:5)

at Authenticator.bound [as deserializeUser] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)

at SessionStrategy.authenticate (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/strategies/session.js:49:28)

at attempt (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/middleware/authenticate.js:341:16)

at authenticate (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/middleware/authenticate.js:342:7)

at /Users/thomaskenedy/sandbox/LegoSix/api/policies/passport.js:43:23

at initialize (/Users/thomaskenedy/sandbox/LegoSix/node_modules/passport/lib/middleware/initialize.js:62:5)

at module.exports (/Users/thomaskenedy/sandbox/LegoSix/api/policies/passport.js:41:24)

at routeTargetFnWrapper (/usr/local/lib/node_modules/sails/lib/router/bind.js:179:5)

at callbacks (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:164:37)

at param (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:138:11)

at pass (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:145:5)

at nextRoute (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:100:7)

at callbacks (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:167:11)

at /usr/local/lib/node_modules/sails/lib/router/bind.js:187:7

at clearHeaders (/usr/local/lib/node_modules/sails/lib/hooks/cors/index.js:209:3)

at routeTargetFnWrapper (/usr/local/lib/node_modules/sails/lib/router/bind.js:179:5)

at callbacks (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:164:37)

at param (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:138:11)

at pass (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:145:5)

at nextRoute (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:100:7)

at callbacks (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:167:11)

at /usr/local/lib/node_modules/sails/lib/router/bind.js:187:7

at sails.router.bind._middlewareType (/usr/local/lib/node_modules/sails/lib/hooks/csrf/index.js:102:11)

at routeTargetFnWrapper (/usr/local/lib/node_modules/sails/lib/router/bind.js:179:5)

at callbacks (/usr/local/lib/node_modules/sails/node_modules/express/lib/router/index.js:164:37)

Details: OrientDB.RequestError: Found class name null or empty

dmarcelino commented 9 years ago

Hello @tommykennedy, do you get the same with OrientDB 2.0.x? Sails-orientDB does not support OrientDB 2.1 yet, check #52.

tommykennedy commented 9 years ago

No I checked it on 2.0.5-snapshot and it also came up with the error. Is there a problem with passing in a Javascript Object to the create method? Is it expecting a string?

dmarcelino commented 9 years ago

Is there a problem with passing in a Javascript Object to the create method?

There shouldn't be as sails-orientdb passes the json type test which is not too different from what you are doing. Is this schemaful or schemaless btw?

tommykennedy commented 9 years ago

The Answer model is defined as

module.exports = {

tableName: 'Answer',
identity: 'Answer',

attributes: {
    id: {
        type: 'string',
        primaryKey: true,
        columnName: '@rid'
    },
    Answer: {
        type: 'JSON'
    },
    question: {
        collection: 'Questions',
        via: 'answers',
    }
}

};

so I would say Schemaful if my understanding is correct.

dmarcelino commented 9 years ago

BTW, this is probably not the cause of your issue but the identity (and collection) of a model must be lower case: docs

tommykennedy commented 9 years ago

I commented out the identity tags and that didn't make a difference. I have attached both models. They are joined by an edge relationship. I think this is where the issue lies.

Found class name null or empty is still coming up and the edge does not get created.

Answer

module.exports = {

tableName: 'Answer',
//identity: 'answer',

attributes: {
    id: {
        type: 'string',
        primaryKey: true,
        columnName: '@rid'
    },
    Answer: {
        type: 'JSON'
    },
    question: {
        collection: 'questions',
        via: 'answers',
    }
}

};

and Question

 module.exports = {
 tableName: 'Questions',
 //identity:'questions',
 joinTableNames: {
  answers: 'answered'
 },

 attributes: {
   id: { type: 'string', primaryKey: true, columnName: '@rid'},
   question  : { type: 'string'},
   answers: {
  collection: 'answer',
  via: 'question',
  dominant:true
  }
}
};

I enabled Oriento Logging and the output gives.

executing query against db waterlineTest: INSERT INTO Answer SET Answer = :paramAnswer0, createdAt = :paramcreatedAt1, updatedAt = :paramupdatedAt2 sending operation command for database waterlineTest executing query against db waterlineTest: UPDATE Answer SET Answer = :paramAnswer0, createdAt = :paramcreatedAt1, updatedAt = :paramupdatedAt2, @rid = :paramrid3 RETURN AFTER WHERE @rid = :param0 sending operation command for database waterlineTest

dmarcelino commented 9 years ago

@tommykennedy, would you mind submitting a PR with a test? You can use 105-delete_customPK.js as a template.

tommykennedy commented 9 years ago

I haven't written any tests before but now is the time to learn. Let me look at the template and attempt it. Are there any docs?

tommykennedy commented 9 years ago

Hi Dario,

I have submitted a failing test.

Tom

dmarcelino commented 9 years ago

Fixed via #119.