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

provisions to identify fields with multiple value #5109

Merged
merged 8 commits into from
Jan 29, 2024
Merged

Conversation

HiteshRepo
Copy link
Contributor

@HiteshRepo HiteshRepo commented Jan 24, 2024

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:

"lookup": {
    "allowMultipleValues": true,
    "allowUnlimitedLength": false,
    "columnName": "Title",
    "listId": "21b45bf2-e495-4582-b114-839577ff8e4f"
}

But choice columns, even though allows to set multiple choices/value, does not have that particular field allowMultipleValues 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:
Choice-List-Multi

Restored list with choice column in site
Restored-Choice-List-Multi
The color does not come through though

Does this PR need a docs update or release note?

  • ✅ Yes, it's included
  • 🕐 Yes, but in a later PR
  • ⛔ No

Type of change

  • 🌻 Feature
  • 🐛 Bugfix
  • 🗺️ Documentation
  • 🤖 Supportability/Tests
  • 💻 CI/Deployment
  • 🧹 Tech Debt/Cleanup

Issue(s)

#5108

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@HiteshRepo HiteshRepo added sharepoint lists category of sharepoint service labels Jan 24, 2024
@HiteshRepo HiteshRepo self-assigned this Jan 24, 2024
Copy link
Contributor

aviator-app bot commented Jan 24, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

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.

Copy link
Contributor

@ryanfkeepers ryanfkeepers left a 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.

Comment on lines 506 to 513
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
}
}
Copy link
Contributor

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:

Suggested change
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
}

Copy link

sonarcloud bot commented Jan 29, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@aviator-app aviator-app bot merged commit 8ac7e6c into main Jan 29, 2024
24 checks passed
@aviator-app aviator-app bot deleted the lists-multiple branch January 29, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lists category of sharepoint service mergequeue sharepoint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants