Open creisle opened 5 years ago
orientdb: 3.0.20 orientjs: 3.0.5 node: v10
Throws an error when the default value of a string field contains white space
const DB_NAME = 'test_whitespace_bug'; const cleanup = async (server, conf) => { await server.dropDatabase({ name: DB_NAME, 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: 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 }); // create the class const dbClass = await db.class.create('whitespace', 'V'); try { // create the string property and default await dbClass.property.create({ name: 'name', type: 'string', default: 'some string with whitespace' }); } catch (err) { await cleanup(server, conf); throw err; } await cleanup(server, conf); };
the error observed was as follows
{ OrientDB.RequestError: Error parsing query: ALTER PROPERTY whitespace.name DEFAULT some string with whitespace ^ Encountered " <IDENTIFIER> "string "" at line 1, column 45. Was expecting one of: <EOF> ";" ... DB name="test_whitespace_bug" Error Code="1" 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: 'Error parsing query:\nALTER PROPERTY whitespace.name DEFAULT some string with whitespace\n ^\nEncountered " <IDENTIFIER> "string "" at line 1, column 45.\nWas expecting one of:\n <EOF> \n ";" ...\n \r\n\tDB name="test_whitespace_bug"\r\n\tError Code="1"', data: {}, isMVCC: [Function], isTokenException: [Function], previous: [], code: 1, identifier: 0, id: 1, type: 'com.orientechnologies.orient.core.sql.OCommandSQLParsingException', hasMore: 0 }
Version Information
orientdb: 3.0.20 orientjs: 3.0.5 node: v10
Behaviour
Throws an error when the default value of a string field contains white space
Steps to reproduce
the error observed was as follows