diff options
-rw-r--r-- | lib/arel/nodes/table_alias.rb | 4 | ||||
-rw-r--r-- | test/nodes/test_table_alias.rb | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/arel/nodes/table_alias.rb b/lib/arel/nodes/table_alias.rb index b32f057117..ebfcb58e64 100644 --- a/lib/arel/nodes/table_alias.rb +++ b/lib/arel/nodes/table_alias.rb @@ -12,6 +12,10 @@ module Arel def table_name relation.respond_to?(:name) ? relation.name : name end + + def engine + relation.engine + end end end end diff --git a/test/nodes/test_table_alias.rb b/test/nodes/test_table_alias.rb new file mode 100644 index 0000000000..fef24bb19e --- /dev/null +++ b/test/nodes/test_table_alias.rb @@ -0,0 +1,16 @@ +require 'helper' +require 'ostruct' + +module Arel + module Nodes + describe 'table alias' do + it 'has an #engine which delegates to the relation' do + engine = Object.new + relation = OpenStruct.new(:engine => engine) + + node = TableAlias.new relation, :foo + node.engine.must_equal engine + end + end + end +end |