Closed martinpengellyphillips closed 3 years ago
renaming a property in the class should have this effect, a new command should not be required.
True, but wouldn't that workflow be:
which isn't obvious and also seems a bit overkill.
@martinpengellyphillips , I think @phpnode meant this syntax:
ALTER PROPERTY <class>.<property> NAME NewNameValue
Look here, please: https://github.com/orientechnologies/orientdb/wiki/SQL-Alter-Property
But be aware, that altering property and class names could detach dependent custom indexes, which is another issue I still think I have to analyze and submit.
Yeah, I understood that. However, I am talking about when in schemaless mode and not using a property. Attempting to use ALTER PROPERTY before creating the property failed for me (or is that a bug?).
Chatting to Luca over on the forum, I see the solution currently is:
UPDATE <class> SET <newField> = <oldField>
UPDATE <class> REMOVE <oldField>
I still think there is a case for a more obvious RENAME command though. I searched for quite a bit on the forum and docs on how to rename a field and came up blank when ALTER PROPERTY didn't work. Perhaps just an addition to the documentation would suffice though, although perhaps a RENAME would help for the case you mention of handling custom indexes.
@lvca @luigidellaquila when I changed the schema from studio, by renaming a property, all the existing properties still exist and only when I insert something new it has the proper schema/property name. Is this the expected behavior?
Edit: Actually checked again and it leaves both the old and the new field name
It would be helpful to have a convenience command in SQL API for renaming a field for all documents (even when no property exists).
Something like:
At present, you have copy all the values to the new field and then drop the old field which is non-obvious for newbies like me ;-)