orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.75k stars 871 forks source link

OrientDB SQL CREATE PROPERTY - LINK and LINKEDCLASS attributes #5459

Closed healiseu closed 3 years ago

healiseu commented 8 years ago

Hi, I am testing CREATE PROPERTY commands with LINK and LINKEDCLASS attributes on OrientDB 2.1.6 and I found the following inconsistency between SQL and HTTP RESTful commands:

CREATE PROPERTY Person.address LINK

This is executed without any problem and you can create LINK records without specifying LINKEDCLASS attribute. I noticed also that you cannot specify LINKEDCLASS during the creation of property and you have to do it secondary with ALTER command

ALTER PROPERTY Person.address LINKEDCLASS Address `

but when you try

http://localhost:2480/property/ADB/Person/address/LINK

You get an error message Syntax error: property named dptr is declared as LINK but linked type is not declared: property / <database> / <class-name> / <property-name> / <property-type> / <link-type> Note that the error message is not correct, it shows there is confusion between link-type and linked-class.... and

http://localhost:2480/property/ADB/Person/address/LINK/Address

This works, property is created with LINK and LINKEDCLASS attributes !!!

From the examples above It is clear that in the first case LINKEDCLASS is OPTIONAL but in the second case LINKEDCLASS is MANDATORY. That does not make sense, I think in both case it should be optional, following the schemaless records choice.

By the way, in the manual pages referring to Restful creation of properties the examples are wrong e.g.

String Property Example: HTTP POST request: http://localhost:2480/class/demo/simpleField should be http://localhost:2480/property/<database>/demo/simpleField

healiseu commented 8 years ago

@luigidellaquila Further to the observations I made above, I found that you can specify LINKEDCLASS attribute during the creation of the property with an SQL command like

CREATE PROPERTY Person.address LINK Address

But this breaks consistency with the

ALTER PROPERTY Person.address LINKEDCLASS Address