Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Mandatory property is not using default value instead errors #1919

Open
gramian opened this issue Jan 16, 2025 · 6 comments
Open

SQL: Mandatory property is not using default value instead errors #1919

gramian opened this issue Jan 16, 2025 · 6 comments
Assignees
Milestone

Comments

@gramian
Copy link
Collaborator

gramian commented Jan 16, 2025

ArcadeDB Version:

ArcadeDB Server v24.11.2 (build 055592c73d27d894c26f3faaf7df22e15c28f03d/1733838531445/main)

OS and JDK Version:

Running on Linux 6.2.0-26-generic - OpenJDK 64-Bit Server VM 17.0.1

The docs state that the default value of properties is null. Now, instantiating a type with a mandatory property but not providing a property value leads to an error instead of using the default value (null if none explicitly set) for this property.

Expected behavior

A record is added and the mandatory property is set with its default value.

Actual behavior

Error on command execution (PostCommandHandler): The property 'doc.num' is mandatory, but not found on record: @doc[]

Steps to reproduce

CREATE DOCUMENT TYPE doc;
CREATE PROPERTY doc.num INTEGER (mandatory true);
INSERT INTO doc;
@robfrank robfrank added this to the 25.1.1 milestone Jan 16, 2025
@robfrank robfrank self-assigned this Jan 16, 2025
@robfrank
Copy link
Collaborator

I'm unable to reproduce the problem.

I've got the error on both studio and test code.

From server log:

Error on command execution (PostCommandHandler): The property 'doc.num' is mandatory, but not found on record: @doc[]

on test:

com.arcadedb.exception.ValidationException: The property 'doc.num' is mandatory, but not found on record: @doc[]

	at com.arcadedb.database.DocumentValidator.throwValidationException(DocumentValidator.java:389)
	at com.arcadedb.database.DocumentValidator.validateField(DocumentValidator.java:43)
	at com.arcadedb.database.DocumentValidator.validate(DocumentValidator.java:38)
	at com.arcadedb.database.MutableDocument.validate(MutableDocument.java:134)
	at com.arcadedb.database.LocalDatabase.createRecordNoLock(LocalDatabase.java:822)
	at com.arcadedb.database.LocalDatabase.lambda$createRecord$17(LocalDatabase.java:793)
	at com.arcadedb.database.LocalDatabase.executeInReadLock(LocalDatabase.java:1414)
	at com.arcadedb.database.LocalDatabase.createRecord(LocalDatabase.java:792)
	at com.arcadedb.database.MutableDocument.save(MutableDocument.java:299)

@gramian
Copy link
Collaborator Author

gramian commented Jan 16, 2025

I don't understand, the error you post is the problem. Maybe I was unclear in my description: The property should be created automatically using the default value, if none is given, then null should be the value of the mandatory property.

@robfrank
Copy link
Collaborator

Ok, I misread the issue.
But, in my mind, if a property is mandatory it must contains a value. Null is not a value.
We can rephrase the doc: if a property is mandatory, a value must be provided. If a property is not mandatory, the default value is null.

@gramian
Copy link
Collaborator Author

gramian commented Jan 16, 2025

Hmm, what is the difference between the attributes mandatory and notnull then?

@lvca
Copy link
Contributor

lvca commented Jan 16, 2025

We could look up to other DBMS, but it makes sense that mandatory means, I'm expecting the property. NotNull means mandatory + can't be null (like with a RDBMS).

@gramian
Copy link
Collaborator Author

gramian commented Jan 16, 2025

I am fine either way. But the docs need updating to be more clear (note to self).

FYI: There is also a workaround:

CREATE DOCUMENT TYPE doc;
CREATE PROPERTY doc.num INTEGER (mandatory true, default ifnull(null,null));
INSERT INTO doc;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants