Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Cluster Extension loading when custom XML is reloaded #1471

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

dhchandw
Copy link
Collaborator

  • Making sure cluster extension is not duplicated when custom XML is reloaded
  • Added a MANUFACTURER_CODE_DERIVED column since NULL!=NULL in SQL
  • Added SIDE to the UNIQUE constraint in attributes
  • Added logic to catch duplicates during loading before insertion

* Making sure cluster extension is not duplicated when custom XML is reloaded
* Added a MANUFACTURER_CODE_DERIVED column since NULL!=NULL in SQL
* Added SIDE to the UNIQUE constraint in attributes
* Added logic to catch duplicates during loading before insertion
* Added relevant tests
@dhchandw dhchandw marked this pull request as ready for review October 25, 2024 14:37
@dhchandw dhchandw requested a review from ethanzhouyc October 25, 2024 14:38
@@ -655,7 +699,7 @@ async function insertClusterExtensions(db, packageId, knownPackages, data) {
)}) AND CODE = ?`,
data.map((cluster) => [cluster.code])
)
.then((rows) => {
.then(async (rows) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never been a fan of this. Just break the code into separate statements using await

@@ -678,17 +722,38 @@ async function insertClusterExtensions(db, packageId, knownPackages, data) {
// NOTE: This code must stay in sync with insertClusters
if ('commands' in data[i]) {
let cmds = data[i].commands
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let cmds = filterDuplicates(
db,
packageId,
data[i].commands,
['code', 'manufacturerCode', 'source'],
'command'
)

return Promise.all([pCommand, pAttribute, pEvent]).catch((err) => {
if (err.includes('SQLITE_CONSTRAINT') && err.includes('UNIQUE')) {
env.logDebug(
`CRC match for file with package id ${packageId}, skipping parsing.`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message does not seem right. Also use env.logWarning or env.logError

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an error or a warning. We get to this point if we try to reload a cluster extension for a top-level package that already has it.

@dhchandw dhchandw changed the title Handling Cluster Extension loading when custom XML is reloaded: Handling Cluster Extension loading when custom XML is reloaded Oct 28, 2024
@dhchandw dhchandw requested a review from brdandu October 28, 2024 14:10
@@ -170,12 +170,12 @@ exports.testMatterCustomZap =

exports.totalClusterCount = 111
exports.totalDomainCount = 20
exports.totalCommandArgsCount = 1786
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am always a little cautious about tests changing...could you explain to me why you did this please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the unique constraints in the schema were not being hit because for standard clusters, attributes, etc we had manufacturer code set to NULL and NULL does not equal to NULL in SQL. When I added a derived column to circumvent this, I found a duplicate command in zcl-builtin/silabs/demo.xml. With my changes this duplicate command wouldn't be loaded in and hence the command count decreased by one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, approved

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming CI passes of course

@brdandu brdandu self-requested a review October 29, 2024 13:57
@brdandu
Copy link
Collaborator

brdandu commented Oct 29, 2024

The PR looks good. Please take a look at the unify code gen CI failure.

Copy link
Collaborator

@brdandu brdandu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming codegen failure is due to the fix

@dhchandw dhchandw merged commit 72192d8 into project-chip:master Oct 29, 2024
13 of 14 checks passed
@dhchandw dhchandw deleted the bug/ZAPP-1486 branch October 30, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants