Skip to content

Conversation

@fisehara
Copy link
Contributor

Actually deep freezing the constrainedAbstractSqlModel

Change-type: patch

@flowzone-app flowzone-app bot enabled auto-merge April 19, 2023 11:29
obj.hasOwnProperty(prop) &&
obj[prop] !== null &&
!['object', 'function'].includes(typeof obj[prop])
// `synonyms` is apparently changed later on and cannot be deepFroozen
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is synonyms modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Page-
In the get Proxy here:

synonyms[`${synonym}$${alias}`] = `${canonicalForm}$${alias}`;

});
};

const deepFreezeExceptDefinition = (obj: AnyObject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

ExceptDefinition isn't accurate to what this is attempting to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep corrected.


const table = tables[`${resourceName}$bypass`];

const permissionsTable = (tables[permissionResourceName] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't assign to tables[permissionResourceName] then all these changes to permissionsTable are essentially noops?

@fisehara fisehara force-pushed the fisehara/fixing-deep-freeze branch from 6675183 to 8efc9f3 Compare April 26, 2023 10:59
@fisehara fisehara requested a review from Page- April 26, 2023 11:00
Actually deep freezing the `constrainedAbstractSqlModel`

Change-type: patch
Signed-off-by: Harald Fischer <harald@balena.io>
Signed-off-by: fisehara <harald@balena.io>
@fisehara fisehara force-pushed the fisehara/fixing-deep-freeze branch from 8efc9f3 to d285613 Compare May 4, 2023 18:52
Comment on lines +721 to +723
// `synonyms` is changed later on in the constrainedAbstractSqlModel.symbols get proxy
// `tables` is changed later on in the constrainedAbstractSqlModel.tables get proxy
!['synonyms', 'tables'].includes(prop) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the _.cloneDeep in

const constrainedAbstractSqlModel = _.cloneDeep(abstractSqlModel);
not remove the deep-freezing? Because the cloning is intended to avoid hitting issues with modifying the original model which is deep frozen, but if it's not removing the freezing as part of the cloning then that probably needs dealing with

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Page- from my understanding the constrainedAbstractSqlModel should be deep frozen after the deepClone was made.
The freezing part applies to the constrainedAbstractSqlModel and at runtime the Proxies manipulate the dee frozen Object by writing parts to it through the proxies.

So I don't see that the _.cloneDeep is part of the freeze, please correct me here!

@fisehara fisehara requested a review from Page- May 16, 2023 11:38
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