spatialdude / usqlite

μSQLite library module for MicroPython
MIT License
87 stars 18 forks source link

Cannot create table with UNIQUE or PRIMARY KEY #10

Closed fermuch closed 1 year ago

fermuch commented 2 years ago

The following SQL

CREATE TABLE IF NOT EXISTS login(
  key TEXT NOT NULL PRIMARY KEY,
  name TEXT
);

Gives the error:

usqlite_Error: malformed database schema (sqlite_autoindex_login_1) - orphan index

Same happens if I try to set a column as UNIQUE.

spatialdude commented 1 year ago

This error is caused by the SQLITE_OMIT_ATTACH option. This option is now disabled by default - https://github.com/spatialdude/usqlite/blob/131fb3c68751ffe46a55633adcf753a068924bb1/usqlite_config.h#L39