From 8eb542d419047e4bbb35fa16def94d2942a09541 Mon Sep 17 00:00:00 2001 From: Timotej Ecimovic Date: Tue, 23 Feb 2021 11:51:14 -0400 Subject: [PATCH] Load in the "older" specs from the older tags under the domain itself. --- src-electron/db/query-zcl.js | 18 ++++++++++++++++++ test/zcl-loader.test.js | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src-electron/db/query-zcl.js b/src-electron/db/query-zcl.js index ff97a11c13..394f7aaefc 100644 --- a/src-electron/db/query-zcl.js +++ b/src-electron/db/query-zcl.js @@ -1624,6 +1624,24 @@ async function insertDomains(db, packageId, data) { * @returns Promise of insertion. */ async function insertSpecs(db, packageId, data) { + let olders = [] + data.forEach((domain) => { + if ('older' in domain) { + domain.older.forEach((older) => olders.push(older)) + } + }) + if (olders.length > 0) { + await dbApi.dbMultiInsert( + db, + 'INSERT INTO SPEC (PACKAGE_REF, CODE, DESCRIPTION, CERTIFIABLE) VALUES (?, ?, ?, ?)', + olders.map((older) => [ + packageId, + older.specCode, + older.specDescription, + older.specCertifiable ? 1 : 0, + ]) + ) + } return dbApi.dbMultiInsert( db, 'INSERT INTO SPEC (PACKAGE_REF, CODE, DESCRIPTION, CERTIFIABLE) VALUES (?, ?, ?, ?)', diff --git a/test/zcl-loader.test.js b/test/zcl-loader.test.js index 91049c60d9..0f75640b16 100644 --- a/test/zcl-loader.test.js +++ b/test/zcl-loader.test.js @@ -87,7 +87,7 @@ test('test Silabs zcl data loading in memory', () => { .then(() => queryGeneric.selectCountFrom(db, 'GLOBAL_ATTRIBUTE_DEFAULT')) .then((x) => expect(x).toEqual(126)) .then(() => queryGeneric.selectCountFrom(db, 'SPEC')) - .then((x) => expect(x).toEqual(22)) + .then((x) => expect(x).toEqual(38)) .then(() => dbApi.dbAll( db,