-
Notifications
You must be signed in to change notification settings - Fork 214
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
Depict null values in array type ECProperty output #6948
Draft
6ar8nas
wants to merge
24
commits into
master
Choose a base branch
from
Sarunas/array-null-values
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−39
Draft
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e410337
Update the test fixture to be more multi-use applicable
6ar8nas 3966842
use deep equal
6ar8nas ce45610
append ecsql null behavior docs samples
6ar8nas 64ad57c
Merge branch 'master' into Sarunas/array-null-values
6ar8nas fc38873
add struct array type to the docs sample
6ar8nas de7cd0d
Merge branch 'Sarunas/array-null-values' of https://github.com/iTwin/…
6ar8nas ce28366
Remove docs parts about all of the properties of the struct/array to …
6ar8nas 9df8973
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 0824bc7
Merge branch 'master' into Sarunas/array-null-values
6ar8nas d32968e
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 13735f1
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 9c9d405
Merge branch 'master' into Sarunas/array-null-values
6ar8nas c829786
rush change
6ar8nas 5469049
Merge branch 'Sarunas/array-null-values' of https://github.com/iTwin/…
6ar8nas 449776f
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 8a56abb
Bump test schema version to latest
6ar8nas c085589
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 8221e1b
Remove only on a test
6ar8nas 20a09bb
rename bim file
6ar8nas 8bf77e7
Merge branch 'master' into Sarunas/array-null-values
6ar8nas 0bc48b3
Merge remote-tracking branch 'origin/master' into Sarunas/array-null-…
soham-bentley 7f8a573
Merge remote-tracking branch 'origin/master' into Sarunas/array-null-…
soham-bentley c2ef552
Merge remote-tracking branch 'origin/master' into Sarunas/array-null-…
soham-bentley e3f1f21
Merge remote-tracking branch 'origin/master' into Sarunas/array-null-…
soham-bentley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the behavior that has been controversial. @pmconne
There are three possible behaviors:
1 - accept the array as input and persist including the nulls.
2 - consider the array invalid if it has any null inputs.
3 - silently prune the null entries in the array, e.g. persist
[false, true, false]
I do not think it's acceptable to prune the nulls from the array so only options 1 and 2 are OK.
I think #1 is the best option but I could be convinced to accept #2 if we're sure no one will ever want to be able to have a sparse array or have a fixed length array where the use null to indicate that an entry is not yet set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we permit the possibility of sparse arrays then everywhere we define a TypeScript interface representing any array, we must define it as
Array<T | undefined>~ instead of
T[]`. We certainly don't do that today, and I don't think that it would make anyone's life better.If sparse arrays became a requirement at some point, couldn't we consider a custom attribute permitting null entries, similar to how we have
IsNullable
for primitive properties?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, these changes only solve the fact that if nulls are already present in the DB, we display the data accurately as we have it. The sparse arrays have already been possible, it's just that we have been using the 3rd behavior that Colin has described above for representation, while storing the data into the respective database columns as has been input for us including all of the nulls and that seems like a bug.
Is it a must to match all of the TypeScript interfaces to what exactly can be stored on the native side immediately? Given the business justification some time in the future, the only needed change would be switching up the interfaces on the TS side. If the interfaces are kept as is and everyone were strict about using them, this behavior should not ever be hit (though iTwin/itwinjs-backlog#1063 suggests it's not as uncommon) and the nulls wouldn't ever be persisted in the database, making this whole problem redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over a discussion, we agreed to run a SQL script through iQuacs to count null data entries in array properties, thus determining whether there is actual usage of sparse arrays. If there is any, it was agreed to move forward with these changes and fix the currently undocumented null stripping from output, and if not - throw an error on finding a null inside an array.