From 1ae471aa8c15c7a4a4983a04e5335b056fb20e9b Mon Sep 17 00:00:00 2001 From: lvca Date: Fri, 24 May 2024 11:18:46 +0200 Subject: [PATCH] fix: SQL INSERT, improved the exception in case the type name is missing Fixed issue #1612 --- .../arcadedb/query/sql/executor/CreateRecordStep.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/engine/src/main/java/com/arcadedb/query/sql/executor/CreateRecordStep.java b/engine/src/main/java/com/arcadedb/query/sql/executor/CreateRecordStep.java index 42cb866d8..84e81273e 100644 --- a/engine/src/main/java/com/arcadedb/query/sql/executor/CreateRecordStep.java +++ b/engine/src/main/java/com/arcadedb/query/sql/executor/CreateRecordStep.java @@ -19,6 +19,7 @@ package com.arcadedb.query.sql.executor; import com.arcadedb.database.MutableDocument; +import com.arcadedb.exception.CommandSQLParsingException; import com.arcadedb.exception.TimeoutException; import com.arcadedb.schema.DocumentType; import com.arcadedb.schema.LocalEdgeType; @@ -36,6 +37,10 @@ public class CreateRecordStep extends AbstractExecutionStep { public CreateRecordStep(final String typeName, final CommandContext context, final int total) { super(context); + + if (typeName == null || typeName.isEmpty()) + throw new CommandSQLParsingException("Record type is not specified"); + this.typeName = typeName; this.total = total; } @@ -77,7 +82,7 @@ else if (type instanceof LocalEdgeType) return new UpdatableResult(instance); } finally { - if( context.isProfiling() ) { + if (context.isProfiling()) { cost += (System.nanoTime() - begin); } } @@ -92,7 +97,7 @@ public String prettyPrint(final int depth, final int indent) { final StringBuilder result = new StringBuilder(); result.append(spaces); result.append("+ CREATE EMPTY RECORDS"); - if( context.isProfiling() ) { + if (context.isProfiling()) { result.append(" (").append(getCostFormatted()).append(")"); } result.append("\n");