Skip to content

UNIQUE with FILESTORAGE not Working! #1148

Open

Description

@xxsoadxx

When i set attach filestorage to UNIQUE example stop working

Expected result: Error: Cannot insert record, because it already exists in unique index
Actual Result: All row inserted

Code:

    ATTACH FILESTORAGE DATABASE testdb("./testdb.json");
    USE testdb;
    CREATE TABLE usersTable (id INT UNIQUE, name NVARCHAR(255))
    INSERT INTO usersTable VALUES (1,"Andrey")
    INSERT INTO usersTable VALUES (2,"Kate")
    INSERT INTO usersTable VALUES (3,"Kate")
    INSERT INTO usersTable VALUES (3,"Andrey")

Activity

  1. added this to the v5.0.0 milestone on Nov 9, 2026
  2. shaktimaan00 commented on Nov 11, 2026

    @shaktimaan00
    Contributor

    Tracked down the cause: CREATE TABLE on an engine-backed table (FILESTORAGE here) calls the engine's createTable() and returns before the code that wires up table.insert() — the function that actually checks PRIMARY KEY/UNIQUE. So FILESTORAGE tables never get table.insert() at all, and INSERT falls back to a plain append.

    Opened a fix with a regression test covering both FILESTORAGE and LOCALSTORAGE (same root cause on that engine, with an extra wrinkle on reload): #2977

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions