Skip to content

Updating a table with PK and direct data assignment throws an error #1989

@tevanburen

Description

@tevanburen

For tables with primary key constraints that had their data set using example_db.tables.example_table.data = []; , running an update statement is throwing an error for me. I'll attach pseudo-code below, and here's a link to an example on jsfiddle: https://jsfiddle.net/0wmhx149/15/

Updating data with no pk works fine:

// pseudo-code
a = new alasql.Database();
a.exec("create table with no pk");
a.tables.table.data = [ some data ] ;
a.exec("update table");
// update runs correctly

Updating data with pk works fine if using insert statements:

// pseudo-code
a = new alasql.Database();
a.exec("create table with no pk");
a.exec("insert some data");
a.exec("update table");
// update runs correctly

Updating data with pk and direct assignment fails

// pseudo-code
a = new alasql.Database();
a.exec("create table with pk");
a.tables.table.data = [ some data ] ;
a.exec("update table");
// update throws an error

The error is Something wrong with index on table

Two obvious workarounds are

  1. Don't use PKs
  2. Don't directly assign data

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions