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

java.lang.ClassCastException Query Builder Error (v3.X.X) #377

Closed
creisle opened this issue Jun 26, 2019 · 5 comments
Closed

java.lang.ClassCastException Query Builder Error (v3.X.X) #377

creisle opened this issue Jun 26, 2019 · 5 comments
Assignees
Labels

Comments

@creisle
Copy link

creisle commented Jun 26, 2019

System information

Orientjs version: 3.0.5
orientdb version: 3.0.20
node version: v10.13.0

Expected Behaviour

The insert operation to suceed

Actual Behaviour

Throws this error

{ OrientDB.RequestError: null
    at child.Operation.parseError (/home/node_modules/orientjs/lib/client/network/protocol37/operation.js:1224:13)
    at child.Operation.consume (/home/node_modules/orientjs/lib/client/network/protocol37/operation.js:566:35)
    at ONetworkConnection.Connection.process (/home/node_modules/orientjs/lib/client/network/conn.js:462:17)
    at ONetworkConnection.Connection.handleSocketData (/home/node_modules/orientjs/lib/client/network/conn.js:344:20)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  name: 'OrientDB.RequestError',
  message: null,
  data: {},
  isMVCC: [Function],
  isTokenException: [Function],
  previous: [],
  code: 5,
  identifier: 0,
  id: 1,
  type: 'java.lang.ClassCastException',
  hasMore: 0 }

Minimum Reproducible Example

const {OrientDBClient} = require('orientjs');

const test = async (conf) => {
    const server = await OrientDBClient.connect({
        host: conf.DB_HOST,
        port: conf.DB_PORT
    });
    await server.createDatabase({
        name: DB_NAME,
        username: conf.DBS_USER,
        password: conf.DBS_PASS
    });
    const db = await server.session({
        name: DB_NAME,
        username: conf.DBS_USER,
        password: conf.DBS_PASS
    });
    // set up the schema
    await db.command('create class Parent extends V').all();
    await db.command('create class Position').all();
    await db.command('create property Parent.position Embedded Position');
    await db.command('create property Position.pos INTEGER (mandatory TRUE, MIN 1)').all();

    // now create the record using the query builder
    let record;
    try {
        record = await db.insert().into('Parent').set({
            position: {'@class': 'Position', pos: 1}
        }).one();
    } catch (err) {
        await cleanup(server, conf);
        throw err;
    }
    await cleanup(server, conf);
    return record;
};

I think this has something to do with the "MIN" constraint

@creisle
Copy link
Author

creisle commented Jun 26, 2019

It also worth nothing that I can create this record using the same class schema successfully when done though the db console bypassing orientjs

wolf4ood added a commit to orientechnologies/orientdb that referenced this issue Jul 3, 2019
@wolf4ood
Copy link
Member

wolf4ood commented Jul 3, 2019

Hi @creisle

the main problem is on the wired protocol. OrientJS when serializing number uses Long java type, but in this case the property is integer. And that explains the class cast exception. OrientDB
should automatically convert to the declared type on the schema. I've provided a fix. It is on testing now. If the tests passes it will be available in the next release

Thanks

Enrico

wolf4ood added a commit to orientechnologies/orientdb that referenced this issue Jul 3, 2019
wolf4ood added a commit to orientechnologies/orientdb that referenced this issue Jul 3, 2019
@wolf4ood
Copy link
Member

wolf4ood commented Jul 3, 2019

Hi @creisle

the fix has been merged. It will be available in the next OrientDB 3.0.22 release

Thanks

@wolf4ood wolf4ood closed this as completed Jul 3, 2019
@wolf4ood wolf4ood added the bug label Jul 3, 2019
@creisle
Copy link
Author

creisle commented Jul 3, 2019

Great! Thank you :)

@creisle
Copy link
Author

creisle commented Jul 16, 2019

Hi @wolf4ood,

I just tried this is orientdb 3.0.22 and the error is still there

creisle added a commit to bcgsc/pori_graphkb_api that referenced this issue Dec 24, 2020
Addresses: KBDEV-178,KBDEV-343
Relates-to: orientechnologies/orientjs#377
creisle added a commit to bcgsc/pori_graphkb_api that referenced this issue Dec 24, 2020
Relates-to: orientechnologies/orientjs#377
Relates-to: KBDEV-178,KBDEV-343
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