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 parsing query on select from list of record Ids (v3) #376

Open
creisle opened this issue Jun 12, 2019 · 3 comments
Open

Error parsing query on select from list of record Ids (v3) #376

creisle opened this issue Jun 12, 2019 · 3 comments
Assignees
Labels

Comments

@creisle
Copy link

creisle commented Jun 12, 2019

Version info

orientdb version: 3.0.14
orientjs version: 3.0.5
nodejs version: v10.13.0

Expected Behaviour

The same query previously worked in v2.2.X and works when done in the orientdb console but throws an error when using orientjs v3+

Observed Behaviour

throws the following error message

Unhandled rejection OrientDB.RequestError: Error parsing query:
SELECT * FROM [:bob, :alice]
            ^
Encountered " <FROM> "FROM "" at line 1, column 10.
Was expecting one of:
    <EOF> 

Min Reproducible Example

const cleanup = async (server, conf) => {
    await server.dropDatabase({
        name: 'test_select_from_list',
        username: conf.DBS_USER,
        password: conf.DBS_PASS
    });
    await server.close();
};

const test = async (conf) => {
    const server = await OrientDBClient.connect({
        host: conf.DB_HOST,
        port: conf.DB_PORT
    });
    await server.createDatabase({
        name: 'test_select_from_list',
        username: conf.DBS_USER,
        password: conf.DBS_PASS
    });
    const db = await server.session({
        name: 'test_select_from_list',
        username: conf.DBS_USER,
        password: conf.DBS_PASS
    });
    let bob,
        alice;
    try {
        // create some vertices
        ([bob, alice] = await Promise.all([
            db.command('CREATE VERTEX V SET name = \'bob\'').all(),
            db.command('CREATE VERTEX V SET name = \'alice\'').all()
        ]));
    } catch (err) {
        await cleanup(server, conf);
        throw err;
    }
    // do the error prone select
    try {
        // create some vertices
        const result = await db.query('SELECT * FROM [:bob, :alice]', {bob: bob['@rid'], alice: alice['@rid']}).all();
        await cleanup(server, conf);
        return result;
    } catch (err) {
        await cleanup(server, conf);
        throw err;
    }
};
@creisle
Copy link
Author

creisle commented Jul 18, 2019

Note that this may be related to #380 ? Unsure if select from list of records is treated the same as filtering against a list of records

@wolf4ood
Copy link
Member

Hi @creisle

i've checked this syntax is not supported

SELECT * FROM [:bob, :alice]

if you want to use parameters in the target you have to use one 1 param like this

SELECT * FROM :target

let me know if this helps

Thanks

@wolf4ood wolf4ood self-assigned this Jul 29, 2019
@creisle
Copy link
Author

creisle commented Jul 29, 2019

@wolf4ood I get a different error when i try that

const result = await db.query(
    'SELECT * FROM :people', 
    {params: {people: [bob['@rid'], alice['@rid']]}}
).all();

error message

{ OrientDB.RequestError: Cannot use colleciton as target: [null, null]
	DB name="test_select_from_list"
    at child.Operation.parseError (/home/creisle/git/knowledgebase/knowledgebase_api/node_modules/orientjs/lib/client/network/protocol37/operation.js:1224:13)
    at child.Operation.consume (/home/creisle/git/knowledgebase/knowledgebase_api/node_modules/orientjs/lib/client/network/protocol37/operation.js:566:35)
    at ONetworkConnection.Connection.process (/home/creisle/git/knowledgebase/knowledgebase_api/node_modules/orientjs/lib/client/network/conn.js:462:17)
    at ONetworkConnection.Connection.handleSocketData (/home/creisle/git/knowledgebase/knowledgebase_api/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:
   'Cannot use colleciton as target: [null, null]\r\n\tDB name="test_select_from_list"',
  data: {},
  isMVCC: [Function],
  isTokenException: [Function],
  previous: [],
  code: 5,
  identifier: 0,
  id: 1,
  type:
   'com.orientechnologies.orient.core.exception.OCommandExecutionException',
  hasMore: 0 }

I can select from a collection when not using parameters (ex. if I sub them in directly)

const result = await db.query(`SELECT * FROM [${bob['@rid']}, ${alice['@rid']}]`).all();

creisle added a commit to bcgsc/pori_graphkb_api that referenced this issue Dec 24, 2020
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