feature idea - relationship aliases

Issue #3393 wontfix
jvanasco created an issue

(I'm not sure the best venue for this suggestion. If it's the mailinglist or other.)

While auditing my code, I realized that it can be tricky to understand what it going on in a relationship, as much functionality is controlled by kwargs.

Would it possibly be useful to newcomers if there were aliases for relationship and backref?

basically the idea would be something like:

sqlalchemy.orm.relationships.one_2_many
sqlalchemy.orm.relationships.one_2_one

this way, usage of "uselist=False" doesn't get obscured in a list of kwargs

Comments (4)

  1. Mike Bayer repo owner

    I'm -1 on this because it will just be more confusing which form people are supposed to be using. While I've published versions of these kinds of helpers in places like http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/ and https://bitbucket.org/zzzeek/pycon2014_atmcraft , they remain an "outside" thing so that nobody is wondering what SQLAlchemy's primary API is.

    At the moment we already have declarative vs. classical, and backref vs. back_populates (per #3390 we will be pushing for the latter), already enough variants for new users to be puzzled about.

  2. jvanasco reporter

    That's fair. My concern is really that setting up a one_2_one is very verbose. I saw a bit of confusion some Stack Overflow questions too. It looks like something that could be simplified somehow, though I don't know how.

  3. Log in to comment