orientechnologies / orientechnologies/orientdb-studio
Server side functions: Error and confusion with id and @rid
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 128
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
This was replicated in orientdb 2.0.8, 2.0.9 and 2.0.10.
There seems to be a hidden id attribute that causes errors and confusion.
If the following SELECT command is executed:
select from #5:0
then the following result is returned:
{
"result": [
{
"@type": "d",
"@rid": "#5:0",
"@version": 2,
"@class": "OUser",
"name": "admin",
"password": "{SHA-256}8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918",
"status": "ACTIVE",
"roles": [
"#4:0"
],
"@fieldTypes": "roles=n"
}
],
"notification": "Query executed in 0.014 sec. Returned 1 record(s)"
}
This result is desired and expected.
However, when selecting attributes:
select id, @rid, name from #5:0
Then "id" should cause an error, because there is no id attribute for the vertex.
But instead, Id turns into @rid and @rid into rid:
{
"result": [
{
"@type": "d",
"@rid": "#-2:0",
"@version": 0,
"rid": "#5:0",
"name": "admin",
"@fieldTypes": "rid=x"
}
],
"notification": "Query executed in 0.019 sec. Returned 1 record(s)"
}
If a class has an own "id" attribute:
select id, parent_id, name from #12:1
Then it is displayed accordingly:
{
"result": [
{
"@type": "d",
"@rid": "#-2:0",
"@version": 0,
"id": "de.05", <----- This is the correct result!
"parent_id": "de",
"name": "Nordrhein-Westfalen"
}
],
"notification": "Query executed in 0.02 sec. Returned 1 record(s)"
}
But an error is returned, when sorting by that attributes:
com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #56: Ordering mode 'ID' not supported. Valid is 'ASC', 'DESC' or nothing ('ASC' by default)
Command: select id, parent_id, name from #12:0 order by parent_id, id
----------------------------------------------------------------^
My suggestion and request in this regard would be:
- If projections are specified, then only those attributes should be returned.
- It is sometimes helpful to have row numbers, but they should be provided with an SQL function, for example, rownumber (). Because then the column could be named at will and no conflict with class attribute names arises.
- The key for the data in the serialized JSON object should be named after the object in a server-side function. The standard key results should be used, if an expression is returned.
For Example:
...
return items;
Then, I would like to see:
{
"items": [
(returnd data row objects)
],
"notification": "Query executed in 0.02 sec. Returned 1 record(s)"
}
I appreciate your work very much and would like to express my gratitude for your fantastic orientdb.
Kind regards,
Arne
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's SELECT projection and ORDER BY examples, including the cases involving id, @rid, and a class-owned id attribute. Compare the returned records and parsing error with the requested behavior; done means projections and ordering distinguish real attributes from reserved identifiers without the reported confusion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100