Please sign in to comment.
Add Dataset#unused_table_alias, for generating a table alias that has…
… not yet been used in the query This method already existed in a slightly different form as one of the protected eager_graph helper methods named eager_unique_table_alias. However, since it is a generally useful method, it is being made one of the public core dataset methods. What this method allows you do to give the dataset a table identifier (any object acceptable by alias_symbol), and have it return a symbol representing an alias that has yet been used in the dataset: DB[:test].unused_table_alias(:test) # => :test_0 It's expected use case is where you want to join a table to a dataset, but you aren't sure if the table you are joining is already been referenced elsewhere in the dataset, and you want a unique identifier to refer to it: aliaz = ds.unused_table_alias(:table_name) ds.join(:table_name.as(aliaz), ...) Before, there wasn't an easy way to do this on a non-model dataset (since only model datasets had the eager_unique_table_alias defined). Since eager_unique_table_alias is no longer needed, it has been removed.
- Loading branch information...
Showing with 54 additions and 22 deletions.