Skip to content

Conversation

@jvllmr
Copy link
Contributor

@jvllmr jvllmr commented Mar 5, 2025

Fixes: #12398
This PR makes the error message on conflicting loader strategies more verbose to help with debugging

Description

I changed the omitted error messages and the tests covering it.

Checklist

This pull request is:

  • A documentation / typographical / small typing error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

@jvllmr jvllmr force-pushed the strategy-conflict-more-verbose branch from 80a6ff4 to b15a462 Compare March 5, 2025 20:26
@jvllmr jvllmr requested a review from zzzeek March 5, 2025 20:28
Fixes: sqlalchemy#12398
this commit makes the error message on conflicting loader strategies more verbose to help with debugging
@jvllmr jvllmr force-pushed the strategy-conflict-more-verbose branch from b15a462 to 41ebcaf Compare March 5, 2025 20:49
r"Loader strategy replacement "
r"ORM Path\[Mapper\[Order\(orders\)\] -> Order.user_id\] "
r"is in conflict with existing strategy "
r"ORM Path\[Mapper\[Order\(orders\)\] -> Order.user_id\]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this doesn't seem to add much value, since the two sides are the same.

@zzzeek do we have also a way of getting what option is used in each part of the path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought bringing in _LoadElement.strategy might add more value to this, but I realised that it is also equal in a lot of cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not really sure, I haven't looked at this code in a long time. I do know it's vastly simpler code than it was in 1.4 and earlier

@CaselIT
Copy link
Member

CaselIT commented Oct 24, 2025

@zzzeek do you think we can find that information to use in the exception or it's not easily available?

Signed-off-by: Jan Vollmer <jan@vllmr.dev>
Signed-off-by: Jan Vollmer <jan@vllmr.dev>
@jvllmr
Copy link
Contributor Author

jvllmr commented Oct 25, 2025

I have re-iterated on this PR and found a way to create a verbose representation of the LoadElement. My solution involves more than simply accessing attributes. Therefore, I placed the logic in the __str__ magic method on _LoadElement. I would be happy to hear what you think about this.

@CaselIT
Copy link
Member

CaselIT commented Oct 28, 2025

thanks they do look a bit more informative

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

Successfully merging this pull request may close these issues.

Add existing strategy to conflicting strategies error message

3 participants