Enable SQL CREATE PROPERTY to set ATTRIBUTES such as NOT NULL, MANDATORY, and READONLY
See original GitHub issuePresently quite a few commands are required to create a property in a class that is “not null”, “mandatory”, or “read only”. For example:
CREATE Property User.username STRING
ALTER PROPERTY User.username MANDATORY true
ALTER PROPERTY User.username NOTNULL true
ALTER PROPERTY User.username READONLY true
It would be convenient to be able to do the following (or a mix of the attributes):
CREATE Property User.username STRING MANDATORY NOTNULL READONLY
These attributes would come at the end of the statement. For example if this property was a linked element:
CREATE Property Employee.supervisor LINK Employee MANDATORY NOTNULL READONLY
This would make defining properties in SQL much more succinct. Other properties could be defined as well (DEFAULT, MIN, MAX, etc.). It appears that this change could be made in the OCommandExecutorSQLCreateProperty parse and execute methods.
If this seems like a good feature, I would be willing to create a PR.
Issue Analytics
- State:
- Created 8 years ago
- Comments:33 (31 by maintainers)
Top Results From Across the Web
Database Properties (Options Page) - SQL Server
Allow null values for all user-defined data types or columns that are not explicitly defined as NOT NULL during a CREATE TABLE or...
Read more >Non-nullable property must contain a non-null value when ...
Right click your Project title > Properties > Application > Packaging > Under the "Build" section > Set "Nullable" = "Enable" in the ......
Read more >SQL - Alter Property · OrientDB Manual
Attribute Type Description
MANDATORY Boolean Defines whether the property requires a value.
NAME String Defines the property name.
TYPE String Defines a property type.
Read more >SQL NOT NULL Constraint - W3Schools
SQL NOT NULL Constraint. By default, a column can hold NULL values. · SQL NOT NULL on CREATE TABLE. The following SQL ensures...
Read more >13.1.20 CREATE TABLE Statement - MySQL :: Developer Zone
If you do not have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Little Bobby Tables is always in my heart 😆
I think UNSAFE just didn’t work 😉 What I’m trying to do with the new grammar is to make things as strict as possible, to avoid corner cases and have predictable behavior.
Adding new reserved keywords is an option, but it can make migrations very tricky, so I always try to avoid it if I can, in this case I think commas are an acceptable alternative.
Thanks
Luigi
Thanks for the feedback @mmacfadden. Will create a new issue.