InsertManager#insert doesn't return self, not allowing it to be chainable
krainboltgreene opened this issue · 3 comments
krainboltgreene commented
Seems like most methods on these Managers are chainable but oddly this one isn't?
vipulnsward commented
@krainboltgreene many other managers, or other methods from this manager don't return self
as well(some are setters). Whats the use case you would like this to return self
.
krainboltgreene commented
@vipulnsward Is that actually true? Here's the methods that are chainable:
SelectManager#skip
,SelectManager#lock
,SelectManager#on
,SelectManager#group
,SelectManager#from
,SelectManager#join
,SelectManager#outer_join
,SelectManager#having
,SelectManager#project
,SelectManager#distict
,SelectManager#distinct_on
,SelectManager#order
,SelectManager#with
,SelectManager#take
,UpdateManager#take
,UpdateManager#order
,UpdateManager#table
,UpdateManager#where
,UpdateManager#set
InsertManager#into
DeleteManager#take
,DeleteManager#from
I mean it seems like it should chain, in the same way UpdateManager#set
chains.
table = Arel::Table.new(:persons)
query = table.where(table[:id] => 1).set(table[:name] => "Kurtis")
string = query.sql
table = Arel::Table.new(:persons)
query = table.insert(table[:name] => "Kurtis")
string = query.to_sql
Instead I have to write (for no discernible reason):
table = Arel::Table.new(:persons)
query = table.tap { |t| t.insert(table[:name] => "Kurtis") }
string = query.to_sql
rafaelfranca commented
Fixed on master.