Open honzasp opened 2 years ago
the reason we parse strings is that we want combinations of columns, and not columns, to be unique. Field names have to be unique within a model, but not globally unique. sqlite doesn't support a group of columns being unique, so we resorted to that.
I think that SQLite does support unique index with multiple columns: https://www.sqlite.org/lang_createindex.html
sqlite> create table types (name text, api_version text);
sqlite> create unique index i on types (name, api_version);
sqlite> insert into types (name, api_version) values ('Book', 'dev');
sqlite> insert into types (name, api_version) values ('Book', 'dev');
Error: UNIQUE constraint failed: types.name, types.api_version
Or we could simply use (api_version, name)
as the primary key in the types
table, so that we don't have to keep track of type ids in chiseld
.
The database
.chiseld.db
contains two tables,types
andtype_names
, that contain a row for every user-definedChiselEntity
:with data that look like:
We should probably normalize this into one table by dropping
type_names
and adding columnsname
andapi_version
totypes
. We should not be parsing strings fromtype_names.name
to get the name and the api version.This is related to #1601