lib/lhm/chunk_insert.rb
# XXX this is extremely brittle and doesn't work when filter contains more
# than one SQL clause, e.g. "where ... group by foo". Before making any
# more changes here, please consider either:
#
# 1. Letting users only specify part of defined clauses (i.e. don't allow
# `filter` on Migrator to accept both WHERE and INNER JOIN
# 2. Changing query building so that it uses structured data rather than
# strings until the last possible moment.
XXX this is extremely brittle and doesn't work when filter contains more
than one SQL clause, e.g.

1. Letting users only specify part of defined clauses (i.e. don't allow
`filter` on Migrator to accept both WHERE and INNER JOIN
2. Changing query building so that it uses structured data rather than
strings until the last possible moment.
XXX this is extremely brittle and doesn ' t work when filter contains more than one SQL clause e . g . 1 . Letting users only specify part of defined clauses ( i . e . don ' t allow ` filter ` on Migrator to accept both WHERE and INNER JOIN 2 . Changing query building so that it uses structured data rather than strings until the last possible moment .
def conditions
      if @migration.conditions
        @migration.conditions.
          sub(/\)\Z/, '').
          sub(/where\s(\w.*)\Z/, 'where (\\1)') + ' and'
      else
        'where'
      end
    end
def conditions if @migration . conditions @migration . conditions . sub ( / \) \Z / , '' ) . sub ( / where \s ( \w .*) \Z / , 'where (\\1)' ) + ' and' else 'where' end end
XXX this is extremely brittle and doesn't work when filter contains more
than one SQL clause, e.g.
XXX this is extremely brittle and doesn ' t work when filter contains more than one SQL clause e . g .
# strip ending paren # put any where conditions in parens