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

Consider adding method similar to innerJoinUsingPrimaryKey(), but reverse direction #294

Open
AnyhowStep opened this issue Mar 13, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@AnyhowStep
Copy link
Owner

AnyhowStep commented Mar 13, 2020

innerJoinUsingPrimaryKey() is a convenience function for,

//snip
  .from(myTable)
  .innerJoin(
      otherTable,
      () => tsql.eqPrimaryKeyOfTable(
          myTable,
          otherTable
      )
  )

Using innerJoinUsingPrimaryKey(), you know that you are joining to a single row of otherTable. Because you're joining on otherTable's primary key.


It may be useful to have a function that goes the other way around,

//snip
  .from(myTable)
  .innerJoin(
      otherTable,
      () => tsql.eqPrimaryKeyOfTable(
          otherTable,
          myTable
      )
  )

This time, we could possibly be joining to one or many rows of otherTable, because we're joining on myTable's primary key. Zero, one, or many rows of otherTable may have the same value.

I have no idea what to call this convenience function yet, though.

  • innerJoinUsingSourcePrimaryKey()?
  • innerJoinUsingPrimaryKeyManyRows()?
  • innerJoinUsingPrimaryKey2()?
  • innerJoinUsingPrimaryKeyReverse()?

No clue.


leftJoin and candidateKey joins should also have this "reverse" function.

Without these functions, we have to go back to using tsql.eqPrimaryKeyOfTable().
However, it may not be so bad. In my personal experience, it is not often that I want to do the reverse. And if I do, it usually indicates suspcious code.

However, my personal experience may not be the same as everyone else's experience...

@AnyhowStep AnyhowStep added the enhancement New feature or request label Mar 13, 2020
@AnyhowStep AnyhowStep self-assigned this Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant