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

DataService. _performAndDeleteOfflineOperation incorrectly null checks for offlineService and schema #2019

Open
tejaede opened this issue Jan 10, 2020 · 1 comment
Assignees

Comments

@tejaede
Copy link
Collaborator

tejaede commented Jan 10, 2020

The logic of the following section of DataService. _performAndDeleteOfflineOperation is logically inconsistent.

            if (this.offlineService) {
                tableSchema = this.offlineService.schema[operationType];
                foreignKeys = tableSchema.foreignKeys;
            }

            if (!foreignKeys) {
                foreignKeys = tableSchema._computedForeignKeys ||
                    (tableSchema._computedForeignKeys = Object.keys(operation.changes));
            }

https://github.com/montagejs/montage/blob/master/data/service/data-service.js#L2395-L2404

If this.offlineService is undefined, tableSchema and foreignKeys will not be set in the first conditional. That forces the code to throw in the second condition. !foreignKeys is true so the code enters the block and tableSchema is necessarily undefined.

@tejaede tejaede self-assigned this Jan 10, 2020
@tejaede
Copy link
Collaborator Author

tejaede commented Jan 10, 2020

@marchant

I am not sure what the correct solution is so this issue is designed to track the discussion. This is not a blocker for us.

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

No branches or pull requests

1 participant