Permalink
Browse files

Quote table name in copy and select_columns methods

  • Loading branch information...
1 parent 90aa377 commit 3f04bce985e8b47ff75029b01a1cd6ac14c0aebe @spickermann spickermann committed Jan 9, 2014
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/lhm/chunker.rb
  2. +2 −2 spec/unit/chunker_spec.rb
View
4 lib/lhm/chunker.rb
@@ -51,7 +51,7 @@ def top(stride)
def copy(lowest, highest)
"insert ignore into `#{ destination_name }` (#{ columns }) " +
"select #{ select_columns } from `#{ origin_name }` " +
- "#{ conditions } #{ origin_name }.`id` between #{ lowest } and #{ highest }"
+ "#{ conditions } `#{ origin_name }`.`id` between #{ lowest } and #{ highest }"
end
def select_start
@@ -96,7 +96,7 @@ def columns
end
def select_columns
- @select_columns ||= @migration.intersection.typed(origin_name)
+ @select_columns ||= @migration.intersection.typed("`#{origin_name}`")
end
def validate
View
4 spec/unit/chunker_spec.rb
@@ -22,7 +22,7 @@ def @throttler.run
#noop
end
def @throttler.stride
- 1
+ 1
end
@chunker = Lhm::Chunker.new(@migration, @connection, :throttler => @throttler,
:start => 1,
@@ -89,7 +89,7 @@ def @throttler.stride
:start => 1,
:limit => 2)
@connection.expect(:update, 1) do |stmt|
- stmt.first =~ /where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and foo/
+ stmt.first =~ /where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`/
end
def @migration.conditions

0 comments on commit 3f04bce

Please sign in to comment.