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

Lists.GetByTitle should be case insensitive #991

Closed
1 task done
heinrich-ulbricht opened this issue Oct 11, 2022 · 4 comments
Closed
1 task done

Lists.GetByTitle should be case insensitive #991

heinrich-ulbricht opened this issue Oct 11, 2022 · 4 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@heinrich-ulbricht
Copy link

heinrich-ulbricht commented Oct 11, 2022

Category

  • Bug? But whose is it...

Steps to reproduce

There seems to be a quirk when renaming SharePoint lists and only the casing changes.

Try the following:

  1. Create a new list "Foo and Bar"
  2. Get the list via Lists.GetByTitle("Foo and Bar") - SUCCESS (as expected)
  3. In the browser, select the list title and rename the list to "Foo And Bar" (note the uppercase A)
  4. Get the list via Lists.GetByTitle("Foo And Bar") - FAILURE (unexpected!)
  5. Get the list via Lists.GetByTitle("Foo and Bar") - SUCCESS (but why??)

(Can also be tested with PnP.PowerShell Get-PnPList).

Expected behavior

I expect step 4 above to work. Deep down below it might be a SharePoint quirk, but maybe PnP could do something about it by making this check case insensitive (as list titles cannot only differ in case):

return await this.QueryProperties(selectors).FirstOrDefaultAsync(l => l.Title == title).ConfigureAwait(false);

But this breaks some expression, so implementing this wouldn't be easy?

Not sure about the whole thing. Seems like SharePoint messes something up internally with the title. Feel free to close in this case.

@jansenbe
Copy link
Contributor

@heinrich-ulbricht : fetching lists by title should indeed work case insensitive...trying out a fix now, plan to complete that by tomorrow.

@jansenbe jansenbe self-assigned this Oct 11, 2022
@jansenbe jansenbe added bug Something isn't working area: model 📐 Related to the core SDK models labels Oct 11, 2022
@heinrich-ulbricht
Copy link
Author

@jansenbe It seems it is possible to have multiple lists with the same title. Testing with a concurrent list creation approach I was able to create multiple lists with the same title (they differ in the URL though).

Should this be taken into account? Should GetByTitle even return a list? Should there be a GetListByUrlPart? Or is this something to ignore? Through the UI it seems not possible to create such a situation. But programmatically you can create lists with identical titles.

@jansenbe
Copy link
Contributor

@heinrich-ulbricht : I've just pushed the change, we now use _api/web/lists/getbytitle() just like the batch equivalent of that method already did. Overall I think this will give the best developer experience, changing the output of GetByTitle is not recommended as that would break existing users + the previous implementation also returned the first instance it found or null if none was found.

If you've an application that needs multiple lists having the same title, then using our LINQ implementation is recommended (see https://pnp.github.io/pnpcore/using-the-sdk/basics-getdata.html).

@jansenbe
Copy link
Contributor

@heinrich-ulbricht : closing issue now, fix will be part of the next nightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants