sqldelight icon indicating copy to clipboard operation
sqldelight copied to clipboard

Wrong sqlite generation when removing a column

Open vanniktech opened this issue 2 years ago • 0 comments

SQLDelight Version

2.0.0

IDE Version

IntelliJ 2023.2

Dialect

SQLite

Describe the Bug

Having this table:

CREATE TABLE target (
  id TEXT NOT NULL PRIMARY KEY,
  name TEXT NOT NULL,
  created INTEGER AS Instant,
  updated INTEGER AS Instant,
  coacheeId TEXT NOT NULL,
  cancelledAt INTEGER AS Instant,
  cancelledReason INTEGER AS Int,
  creatorCoachId TEXT
);

and removing 1 the last column, the plugin generates:

CREATE TABLE tmp_target (id TEXT NOT NULL PRIMARY KEY, name TEXT NOT NULL, created INTEGER, updated INTEGER, coacheeId TEXT NOT NULL, cancelledAt INTEGER, cancelledReason INTEGER);
INSERT INTO tmp_target (id, name, created, updated, coacheeId, cancelledAt, cancelledReason) SELECT (id, name, created, updated, coacheeId, cancelledAt, cancelledReason) FROM target;
DROP TABLE target;
ALTER TABLE tmp_target RENAME TO target;

which isn't valid though as you can't have ( & ) around the SELECT part of the query.

Stacktrace

No response

vanniktech avatar Aug 19 '23 15:08 vanniktech