Skip to content

Commit 8120856

Browse files
authored
Merge pull request #463 from ZIMkaRU/bugfix/fix-symbols-pairs-duplication
Fix symbols/pairs duplication
2 parents cfcea64 + 669a1b6 commit 8120856

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

workers/loc.api/sync/dao/dao.better.sqlite.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const {
3333
manageTransaction
3434
} = require('./helpers')
3535

36+
const {
37+
isUpdatable
38+
} = require('../schema/utils')
39+
3640
const {
3741
DbVersionTypeError,
3842
SqlCorrectnessError,
@@ -511,6 +515,7 @@ class BetterSqliteDAO extends DAO {
511515
}
512516

513517
await this._beginTrans(async () => {
518+
const methodCollMap = [...this._getMethodCollMap()]
514519
const tableNames = await this.getTablesNames({ doNotQueueQuery })
515520
const filteredTempTableNames = tableNames.filter((name) => (
516521
name.includes(namePrefix)
@@ -524,11 +529,19 @@ class BetterSqliteDAO extends DAO {
524529
continue
525530
}
526531

532+
const syncSchema = methodCollMap.find(([key, schema]) => (
533+
schema.getModelField('NAME') === name
534+
))?.[1]
535+
const type = syncSchema?.getModelField('TYPE') ?? ''
536+
527537
const projection = model.getModelFieldKeys()
528538
.filter((fieldName) => fieldName !== Model.UID_FIELD_NAME)
529539
.join(', ')
530540

531-
if (isStrictEqual) {
541+
if (
542+
isStrictEqual ||
543+
isUpdatable(type)
544+
) {
532545
await this.query({
533546
action: MAIN_DB_WORKER_ACTIONS.RUN,
534547
sql: `DELETE FROM ${name}`

0 commit comments

Comments
 (0)