Skip to content

Instantly share code, notes, and snippets.

@solnic
Created October 27, 2014 12:59
Show Gist options
  • Save solnic/0b93dbfb2410fd855fbe to your computer and use it in GitHub Desktop.
Save solnic/0b93dbfb2410fd855fbe to your computer and use it in GitHub Desktop.
# without unique column names this is what you need to do to make sure the result set has correct values and there
# are no name clashes
DB[:users].
join_table(:inner, :tasks, user_id: :users__id).
select(:tasks__id___task_id, :users__id___users_id)
# versus this, if we had unique column names by default
DB[:users].natural_join(:tasks).select(:task_id, :user_id)
@hotgazpacho
Copy link

Is this Sequel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment