-
Notifications
You must be signed in to change notification settings - Fork 45
provisions to identify fields with multiple value #5109
Conversation
Current Aviator status
This PR was merged using Aviator. See the real-time status of this PR on the Aviator webapp. Use the Aviator Chrome Extension to see the status of your PR within GitHub.
|
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.
have a nit on func patterns, but otherwise looks good.
src/pkg/services/m365/api/lists.go
Outdated
func setMultipleEnabledByFieldData(val any, colDetails *columnDetails) { | ||
// for columns like 'choice', even though it has an option to hold single/multiple values, | ||
// the columnDefinition property 'allowMultipleValues' is not available. | ||
// Hence we determine single/multiple from the actual field data. | ||
if reflect.TypeOf(val).Kind() == reflect.Slice { | ||
colDetails.isMultipleEnabled = true | ||
} | ||
} |
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.
Preference on general func behavior: rather than setting values a provided object (which causes coupling between the caller and the func), funcs that provide return values and let callers act on them (which provides cohesion without coupling), are easier to maintain in the long term. In this case, it's a better pattern to have a func whose only job is to check whether the value is a slice. Ex:
func setMultipleEnabledByFieldData(val any, colDetails *columnDetails) { | |
// for columns like 'choice', even though it has an option to hold single/multiple values, | |
// the columnDefinition property 'allowMultipleValues' is not available. | |
// Hence we determine single/multiple from the actual field data. | |
if reflect.TypeOf(val).Kind() == reflect.Slice { | |
colDetails.isMultipleEnabled = true | |
} | |
} | |
func isSlice(val any) bool { | |
return reflect.TypeOf(val).Kind() == reflect.Slice | |
} |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
provisions to identify fields with multiple value.
Some fields can hold multiple values and single value based on a property called
allowMultipleValues
.For example,
Lookup
column:But
choice
columns, even though allows to set multiple choices/value, does not have that particular fieldallowMultipleValues
to indicate.So in this PR we are trying determine the same by the stored values while restoring.
Original list with
choice
column in site:Restored list with
choice
column in siteThe color does not come through though
Does this PR need a docs update or release note?
Type of change
Issue(s)
#5108
Test Plan