Skip to content

SQL: UPDATE not triggering schema default value #1814

@gramian

Description

@gramian

ArcadeDB Version:

ArcadeDB Server v24.10.1 (build ac46a0da6ebe4f5d337e50874f3d8a0d1bf092b1/1728751149872/main)

OS and JDK Version:

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

Given a type having a mandatory, notnull property with a default value, where a record is updated with the property in question being empty. Then the default value is not triggered and thus notnull and mandatory attributes trigger an error.

Expected behavior

Update existing record with default value

Actual behavior

Error on command execution (PostCommandHandler)
com.arcadedb.exception.ValidationException: The property 'doc.prop' is mandatory, but not found on record: #1:0@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.updateRecord(LocalDatabase.java:883)
	at com.arcadedb.database.MutableDocument.save(MutableDocument.java:297)
	at com.arcadedb.query.sql.executor.SaveElementStep$1.next(SaveElementStep.java:59)
	at com.arcadedb.query.sql.executor.CountStep.syncPull(CountStep.java:67)
	at com.arcadedb.query.sql.executor.SelectExecutionPlan.fetchNext(SelectExecutionPlan.java:44)
	at com.arcadedb.query.sql.executor.UpdateExecutionPlan.executeInternal(UpdateExecutionPlan.java:64)
	at com.arcadedb.query.sql.parser.UpdateStatement.execute(UpdateStatement.java:126)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:73)
	at com.arcadedb.query.sql.SQLQueryEngine.command(SQLQueryEngine.java:107)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1348)
	at com.arcadedb.server.ServerDatabase.command(ServerDatabase.java:472)
	at com.arcadedb.server.http.handler.PostCommandHandler.executeCommand(PostCommandHandler.java:134)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:113)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:100)
	at com.arcadedb.server.http.handler.AbstractServerHttpHandler.handleRequest(AbstractServerHttpHandler.java:127)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:395)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Thread.java:840)

Steps to reproduce

CREATE DOCUMENT TYPE doc;
CREATE PROPERTY doc.prop STRING (mandatory true, notnull true, default 'Hi');
INSERT INTO doc CONTENT { "prop": "Ho" };
UPDATE doc CONTENT { } WHERE prop = 'Ho';

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions