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

Let models have multiple direct associations with the same type #291

Merged
merged 17 commits into from
Oct 10, 2016

Conversation

gfx
Copy link
Member

@gfx gfx commented Sep 19, 2016

This patch introduces the Aliases class to the runtime library, which allocates table name aliases dynamically.

Resolve #189


In ModelWithDirectAssociation2, the $DEFAULT_RESULT_COLUMNS should be something like this:

  final String[] $DEFAULT_RESULT_COLUMNS = {
    "`m1`.`author`", // this.author.getSafeName()
      "`a2`.`note`", // this.author.associationSchema.note.getSafeName()
      "`a2`.`name`"
    ,
    "`m1`.`author2`", // this.author1.getSafeName()
      "`a3`.`note`", // this.author1.associationSchema.note.getSafeName()
      "`a3`.`name`"
    ,
    "`m1`.`publisher`",
      "`p4`.`name`",
      "`p4`.`started_year`",
      "`p4`.`started_month`",
      "`p4`.`id`"
    ,
    "`m1`.`publisher2`",
      "`p5`.`name`",
      "`p5`.`started_year`",
      "`p5`.`started_month`",
      "`p5`.`id`"
    ,
    "`m1`.`note`",
    "`m1`.`name`"
  };

JOINs:

SELECT * FROM ModelWithDirectAssociation2 AS m1
  LEFT OUTER JOIN Author AS a1 ON
    m1.id = a1.id
  -- ...

@gfx gfx changed the title [WIP] Multiple associations Let models have multiple direct associations with the same type Oct 10, 2016
@gfx gfx merged commit f13e7b9 into master Oct 10, 2016
@gfx gfx deleted the multiple_associations branch October 10, 2016 08:33
@gfx gfx added this to the v3.0.0 milestone Oct 10, 2016
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.

1 participant