Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction.
Apache License 2.0
503
stars
41
forks
source link
WebSQL : Fix getSchema when having more than one multi-entry index. #92
In WebSQL implementation multi-entry indexes are stored in a separate
table. Each 'multientry' table is composed of two columns, one which
name match the multi-entry index name and one column 'id'.
What we expect getSchema method to do is :
When parsing a 'multientry' table,
If there already is an entry in the stores map, add the multi-entry index
to the entry
if not, create an entry in the stores map with only the multi-entry index
When parsing the 'store' table :
If there already is an entry in the stores map, merge all indexes of the
entry with those of the 'store' table.
What getSchema was doing :
When parsing a 'multientry' table :
If there already is an entry in the stores map, replace all indexes of
the entry by the multientry table indexes (id + multientry index)
if not, it works as expected.
When parsing the 'store' table :
if there already is an entry in the stores map, add only the first
recorded index to the store indexes
So if :
Store is parsed before the multientry table (which happens rarely
) the store indexes are overwritten by the multientry table indexes.
There is more than one multi-entry index, only one of the multi entry
indexes is added to the store description.
@mehdirande Thanks for great PR. I have changed a bit so that it fit with strangest compile flag and some failing cases on other tests. Please add unit test if you are in doubt.
In WebSQL implementation multi-entry indexes are stored in a separate table. Each 'multientry' table is composed of two columns, one which name match the multi-entry index name and one column 'id'. What we expect getSchema method to do is : When parsing a 'multientry' table,