-
Notifications
You must be signed in to change notification settings - Fork 15
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
DataRecord improvement: Consider to unify the setup/usage for field_types field_values in DataRecord #105
Comments
Hi @chjuncn is there a reproducible example of Overall I 100% agree that managing two separate dictionaries is ugly and I also would like to make these consistent by just managing one data structure. Finally, can you expand on your text in If my understanding is not complete, please correct me! Also, one current limitation of the existing approach is that users cannot use fields with names that match the top-level fields in (The simplest idea for overcoming name collisions is simply to prefix those internal fields with an underscore and then we could disallow field names with |
I just feel it's too easy to get wrong by using DataRecord in this way.
I was wrong. I was confused by the field_values and system protected_values when I created this issue, that's why I think it's confusing :P
I got this issue as well. I like the simplest solution to solve the collisions. In addition I propose another solution to solve the first issue I mentioned above:
In this way, we separate what we set for data format, and what we have for data.
Overall, resolving name collision has higher priority, we can rename system attributes with '_'. I think my proposal can make the system has clearer logic and easy to use in the future. |
Issues
datarecord.field_types.keys() and datarocrd.field_values.keys() return different sets and they even don't necessarily overlap with each other, which is confusing. And the usage for field_types and field_values seem to be random in DataRecord now.
field_types are generally from Schema setup
field_values setup is simply by datarecord.new_field=value.
So we have different keys for these 2 set, it's easy to get attribute not found in the code. Consider to make them consistent or just use one set all the time.
Possible Further Improvements
Currently all fields including system fields, user-added fields are in same level of data record, they mix together. How about keep system level fields in first level, and all user-added fields into a customized_fields attributes? E.g.
I think it will be easier for the system to manage fields and less confusing, no conflicting from system and user-defined fields.
The text was updated successfully, but these errors were encountered: