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

Allow addition of duplicate entries #402

Closed
2 tasks
claell opened this issue Sep 20, 2023 · 2 comments
Closed
2 tasks

Allow addition of duplicate entries #402

claell opened this issue Sep 20, 2023 · 2 comments

Comments

@claell
Copy link
Contributor

claell commented Sep 20, 2023

Is your feature request related to a problem? Please describe.
In addition to #401, one more thing that I'd like to request. I need to add duplicate entries sometimes. Currently, that does seem to be always silently avoided.

Describe the solution you'd like
Add an argument to the add() function of the library that allows to add duplicate entries, or maybe a general property for the library (?).

Use cases
I want to replicate some export behavior of different sites. There, it can be possible that duplicate entries will be generated for the export. So to identically replicate such exports (even if not good quality), I need this functionality.

Describe alternatives you've considered
Not using this library for that purpose.

Remaining Questions (Optional)
Please tick all that apply:

  • I would be willing to to contribute a PR to fix this issue.
  • This issue is a blocker, I'd be greatful for an early fix.
@MiWeiss
Copy link
Collaborator

MiWeiss commented Sep 20, 2023

Unfortunately, we cannot allow multiple entries with the same key in the same library instance.

The reason for that is that we allow to access entries by key using library.entries_dict, which is one of the most important methods, especially for anyone migrating from v1. Having multiple entries with the same key in the library would result to undefined/unexpected behavior here. I thus deliberately decided against allowing such duplicates.

Workarounds: Your usecase, while certaintly valid, appears to be quite rare and I guess using a workaround would be acceptable. This could e.g. by creating a middleware which maps duplicate key entries to regular entries with a "DUPLICATEKEY" suffix added to the key. You could then write the library to bibtex in memory, followed by a simple str.replace("DUPLICATEKEY","").

@MiWeiss MiWeiss closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
@claell
Copy link
Contributor Author

claell commented Sep 21, 2023

Alright, thanks for providing a workaround. Possibly, one could also add another parameter to the write functions supporting this out of the box (or this won't be needed, depending, how #400 will be dealt with).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants