Skip to content

A scalar written to a LIST OF <number> property is wrapped in a list but not converted: SET longs = 5 is refused ("value of type 'INTEGER' is used") while SET longs = [5] is stored as [5L] #9028

Closed

Description

@tae898

A scalar written to a declared LIST property is stored as a one-element list: INSERT INTO T SET anything = 5 stores [5]. For a LIST OF LONG or LIST OF DOUBLE, a list is converted element by element (longs = [5] is stored as [Long 5], doubles = [5] as [Double 5.0]), but a scalar is wrapped without being converted, and the wrapped element then fails the element check: longs = 5 and doubles = 5 are refused with "has been declared as LIST of 'LONG' but a value of type 'INTEGER' is used. Value: [5]". doubles = 5.0 is accepted because the literal is already a Double. openCypher goes both ways, because CREATE and SET type the literal 5 differently: CREATE (:V {ints: 5}) stores [5] in a LIST OF INTEGER and MATCH ... SET n.ints = 5 is refused ("a value of type 'LONG' is used"), while CREATE (:V {longs: 5}) is refused for a LIST OF LONG ("a value of type 'INTEGER' is used") and SET n.longs = 5 stores [5].

The element conversion for a scalar ofType runs only when the value is already a collection (Type.java#L474-L484); a scalar falls through to the LIST branch, which wraps it as it is (#L754-L767).

Related: #5261 (fixed) was nested LONG types lost on a remote save of MAP and LIST properties; #7777 (fixed) made the wrapped list mutable; #9002 (open) is a JSON array parameter wrapped into a nested list over HTTP. None covers a scalar on a typed list.

Repro

# lib/ holds the engine jar built at the commit under test and its dependencies
javac -cp "lib/*" ScalarIntoListOf.java
java -XX:+UseCompactObjectHeaders --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp "lib/*:." ScalarIntoListOf ./db
import com.arcadedb.database.*;

import java.util.*;

public class ScalarIntoListOf {
  public static void main(String[] args) {
    System.out.println("ArcadeDB " + com.arcadedb.Constants.getRawVersion() + " (" + com.arcadedb.Constants.getBuildNumber() + "), Java "
        + System.getProperty("java.version"));
    try (Database db = new DatabaseFactory(args[0]).create()) {
      db.command("sql", "CREATE DOCUMENT TYPE T");
      db.command("sql", "CREATE PROPERTY T.anything LIST");
      db.command("sql", "CREATE PROPERTY T.longs LIST OF LONG");
      db.command("sql", "CREATE PROPERTY T.doubles LIST OF DOUBLE");
      for (String sql : new String[] { "INSERT INTO T SET anything = 5", "INSERT INTO T SET longs = [5]", "INSERT INTO T SET longs = 5",
          "INSERT INTO T SET doubles = [5]", "INSERT INTO T SET doubles = 5", "INSERT INTO T SET doubles = 5.0" }) {
        final String prop = sql.substring(sql.indexOf("SET ") + 4, sql.indexOf(" =", sql.indexOf("SET ")));
        try {
          final Object[] v = new Object[1];
          db.transaction(() -> v[0] = db.command("sql", sql).next().getElement().get().get(prop));
          final StringBuilder sb = new StringBuilder("[");
          for (Object e : (List<?>) v[0])
            sb.append(e.getClass().getSimpleName()).append(' ').append(e);
          System.out.println(sql + " -> stored " + sb.append("]"));
        } catch (Exception e) {
          System.out.println(sql + " -> refused: " + e.getMessage());
        }
      }
      db.command("sql", "CREATE VERTEX TYPE V");
      db.command("sql", "CREATE PROPERTY V.ints LIST OF INTEGER");
      db.command("sql", "CREATE PROPERTY V.longs LIST OF LONG");
      db.transaction(() -> db.command("opencypher", "CREATE (:V {id: 0})").close());
      for (String cy : new String[] { "CREATE (:V {id: 1, ints: 5})", "MATCH (n:V {id: 0}) SET n.ints = 5", "CREATE (:V {id: 2, longs: 5})",
          "MATCH (n:V {id: 0}) SET n.longs = 5" }) {
        try {
          db.transaction(() -> db.command("opencypher", cy).close());
          System.out.println(cy + " -> accepted");
        } catch (Exception e) {
          Throwable r = e;
          while (r.getCause() != null && r.getCause() != r)
            r = r.getCause();
          System.out.println(cy + " -> refused: " + r.getMessage());
        }
      }
      db.query("sql", "SELECT id, ints, longs FROM V ORDER BY id").forEachRemaining(r -> {
        final StringBuilder sb = new StringBuilder("  V id " + r.getProperty("id") + ":");
        for (String p : new String[] { "ints", "longs" })
          if (r.getProperty(p) instanceof List<?> l)
            sb.append(' ').append(p).append(" = ").append(l).append(" (").append(l.get(0).getClass().getSimpleName()).append(')');
        System.out.println(sb);
      });
    }
  }
}

Output on main cecb369df9 (the engine jar's build stamp is 04bb03ebec, the newest commit in it that is not a merge), Temurin 25.0.4 with -XX:+UseCompactObjectHeaders. Temurin 21.0.12 printed the same lines apart from the Java version on the first line.

ArcadeDB 26.10.1-SNAPSHOT (04bb03ebec07fce19101595d65ca1e3bdf516755), Java 25.0.4
INSERT INTO T SET anything = 5 -> stored [Integer 5]
INSERT INTO T SET longs = [5] -> stored [Long 5]
INSERT INTO T SET longs = 5 -> refused: The property 'T.longs' has been declared as LIST of 'LONG' but a value of type 'INTEGER' is used. Value: [5]
INSERT INTO T SET doubles = [5] -> stored [Double 5.0]
INSERT INTO T SET doubles = 5 -> refused: The property 'T.doubles' has been declared as LIST of 'DOUBLE' but a value of type 'INTEGER' is used. Value: [5]
INSERT INTO T SET doubles = 5.0 -> stored [Double 5.0]
CREATE (:V {id: 1, ints: 5}) -> accepted
MATCH (n:V {id: 0}) SET n.ints = 5 -> refused: The property 'V.ints' has been declared as LIST of 'INTEGER' but a value of type 'LONG' is used. Value: [5]
CREATE (:V {id: 2, longs: 5}) -> refused: The property 'V.longs' has been declared as LIST of 'LONG' but a value of type 'INTEGER' is used. Value: [5]
MATCH (n:V {id: 0}) SET n.longs = 5 -> accepted
  V id 0: longs = [5] (Long)
  V id 1: ints = [5] (Integer)

Versions affected: main cecb369df9 on Temurin 25 and 21 and main 417314c18 (2026-09-17) print the same lines. 26.9.1 prints the same lines except the doubles = 5.0 line, where the literal 5.0 was a FLOAT and is refused ("a value of type 'FLOAT' is used").

Expected: longs = 5 is stored as [5L], as longs = [5] is, or a scalar is refused for every element type alike; either way the answer does not depend on whether the integer arrived as an Integer or a Long, or through CREATE or SET.

Activity

  1. added
    engine
    severity:minor
    on Oct 3, 2026
  2. added this to the 26.10.1 milestone on Oct 3, 2026
  3. added
    in progress
    on Oct 4, 2026
  4. self-assigned this
    on Oct 4, 2026
  5. removed
    in progress
    on Oct 4, 2026
  6. lvca commented on Oct 4, 2026

    @lvca
    Member

    Fixed in #9155 (26.10.1). A single value written to a LIST OF <type> property is now converted to the element type, so longs = 5 stores [5] as a LONG from SQL and from Cypher CREATE/SET. A number outside the element range is now refused instead of being clamped.

    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. tae898 commented on Oct 4, 2026

    @tae898
    ContributorAuthor

    Verified on main at 1b1ae3e477, which contains the #9155 merge c7b93c8fab, with the reproduction from the issue, unchanged, against 0bb737d458, main before that merge, on Temurin 25 with -XX:+UseCompactObjectHeaders and on Temurin 21. Each build printed the same lines on both JDKs:

    statement 0bb737d458 JDK 25 0bb737d458 JDK 21 1b1ae3e477 JDK 25 1b1ae3e477 JDK 21
    INSERT INTO T SET anything = 5 [Integer 5] same [Integer 5] same
    INSERT INTO T SET longs = [5] [Long 5] same [Long 5] same
    INSERT INTO T SET longs = 5 refused (INTEGER) same [Long 5] same
    INSERT INTO T SET doubles = [5] [Double 5.0] same [Double 5.0] same
    INSERT INTO T SET doubles = 5 refused (INTEGER) same [Double 5.0] same
    INSERT INTO T SET doubles = 5.0 [Double 5.0] same [Double 5.0] same
    CREATE (:V {id: 1, ints: 5}) accepted, [Integer 5] same accepted, [Integer 5] same
    MATCH (n:V {id: 0}) SET n.ints = 5 refused (LONG) same accepted, [Integer 5] same
    CREATE (:V {id: 2, longs: 5}) refused (INTEGER) same accepted, [Long 5] same
    MATCH (n:V {id: 0}) SET n.longs = 5 accepted, [Long 5] same accepted, [Long 5] same

    I also checked the Java API with MutableDocument.set. A scalar whose class is not the element type (a Long into LIST OF INTEGER, an Integer into LIST OF LONG, an Integer, Long, or Float into LIST OF DOUBLE, and an Integer into LIST OF STRING) is now stored as one element of the declared type, where each was refused before, and so are the primitive arrays int[] into LIST OF LONG, float[] into LIST OF DOUBLE, double[] into LIST OF FLOAT, and long[] into LIST OF INTEGER, also refused before. An out-of-range number, 3000000000 into LIST OF INTEGER or 40000 into LIST OF SHORT, is refused on both builds, as a list element and as a scalar, through the API and through SQL: the list form was already refused for its range, the scalar form was refused for its class and is now refused for its range, and the message now names the property.

    Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugengineopencypherseverity:minorsql

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions