Skip to content

UNIQUE key doesn't work with localStorage engine. #566

Open

Description

@a-gorbunov

Subject. Going to pull request new test.

Activity

  1. added a commit that references this issue on Jan 31, 2016
  2. a-gorbunov commented on Jan 31, 2016

    @a-gorbunov
    Author

    Same with PRIMARY KEY.

    I created 2 same tables. First - without storage engine. Second - using localStorage.

    CREATE TABLE ExampleTable (field1 string PRIMARY KEY)

    2 table definitions from alasql.databases.exampleDb.tables.exampleTable are posted below:
    No storage:

    {
        "data": [
            {
                "field1": "1"
            }
        ],
        "columns": [
            {
                "columnid": "field1",
                "dbtypeid": "STRING"
            }
        ],
        "xcolumns": {
            "field1": {
                "columnid": "field1",
                "dbtypeid": "STRING"
            }
        },
        "inddefs": {},
        "indices": {},
        "uniqs": {
            "-2097186069": {
                "1": {
                    "field1": "1"
                }
            }
        },
        "uniqdefs": {},
        "identities": {},
        "checkfn": [],
        "checkfns": [],
        "beforeinsert": {},
        "afterinsert": {},
        "insteadofinsert": {},
        "beforedelete": {},
        "afterdelete": {},
        "insteadofdelete": {},
        "beforeupdate": {},
        "afterupdate": {},
        "insteadofupdate": {},
        "pk": {
            "columns": [
                "field1"
            ],
            "onrightfns": "r['field1']",
            "hh": -2097186069
        },
        "defaultfns": "",
        "onupdatefns": "",
        "dirty": true
    }

    Localstorage:

    {
        "data": [
            {
                "field1": "1"
            },
            {
                "field1": "1"
            }
        ],
        "columns": [
            {
                "columnid": "field1",
                "dbtypeid": "STRING"
            }
        ],
        "xcolumns": {
            "field1": {
                "columnid": "field1",
                "dbtypeid": "STRING"
            }
        },
        "inddefs": {},
        "indices": {},
        "uniqs": {},
        "uniqdefs": {},
        "identities": {},
        "checkfn": [],
        "checkfns": [],
        "beforeinsert": {},
        "afterinsert": {},
        "insteadofinsert": {},
        "beforedelete": {},
        "afterdelete": {},
        "insteadofdelete": {},
        "beforeupdate": {},
        "afterupdate": {},
        "insteadofupdate": {}
    }
  3. nickdeis commented on Jan 31, 2016

    @nickdeis
    Contributor

    Related to #409 I think. Since the localStorage implementation serializes tables into localStorage, the unique constraint does not work.

  4. added this to the v5.0.0 milestone on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions