Skip to content

Commit

Permalink
Don't compare .src property of the primary index.
Browse files Browse the repository at this point in the history
The .src property is treated as being different if using dexie-observable's '$$' prefix, resulting in error when upgrading never works if using it.

Resolves issue #1148
  • Loading branch information
dfahlander committed Oct 20, 2020
1 parent a0ff4f0 commit 2f6be57
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/classes/version/schema-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,17 @@ export function getSchemaDiff(oldSchema: DbSchema, newSchema: DbSchema): SchemaD
add: [],
change: []
};
if (oldDef.primKey.src !== newDef.primKey.src &&
!isIEOrEdge // IE and non-chromium Edge has a bug reading spec of primary key
)
{
if (
(
// compare keyPaths no matter if string or string[]
// compare falsy keypaths same no matter if they are null or empty string.
''+(oldDef.primKey.keyPath||'')
) !== (
''+(newDef.primKey.keyPath||'')
) ||
// Compare the autoIncrement flag also
(oldDef.primKey.auto !== newDef.primKey.auto && !isIEOrEdge)) // IE has bug reading autoIncrement prop.
{
// Primary key has changed. Remove and re-add table.
change.recreate = true;
diff.change.push(change);
Expand Down

0 comments on commit 2f6be57

Please sign in to comment.