ankane/pgsync

Using where argument with camelcased column names fails

JohnnyRacer opened this issue · 2 comments

Hello, I've tried to sync another table with camelcase column names. When I use the where argument, I get the following error message. Where it would convert all the column names to lower case. Is there a way to fix this?

Traceback (most recent call last):
        29: from /usr/local/bin/pgsync:23:in `<main>'
        28: from /usr/local/bin/pgsync:23:in `load'
        27: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/exe/pgsync:7:in `<top (required)>'
        26: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/client.rb:35:in `start'
        25: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/client.rb:26:in `perform'
        24: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/sync.rb:67:in `perform'
        23: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/table_sync.rb:28:in `perform'
        22: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/table_sync.rb:244:in `run_tasks'
        21: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/table_sync.rb:305:in `maybe_defer_constraints'
        20: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/table_sync.rb:248:in `block in run_tasks'
        19: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:235:in `each'
        18: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:285:in `map'
        17: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:393:in `work_direct'
        16: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:637:in `with_instrumentation'
        15: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:394:in `block in work_direct'
        14: from /var/lib/gems/2.7.0/gems/parallel-1.23.0/lib/parallel.rb:627:in `call_with_index'
        13: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/table_sync.rb:252:in `block (2 levels) in run_tasks'
        12: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:23:in `perform'
        11: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:182:in `with_notices'
        10: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:24:in `block in perform'
         9: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:194:in `handle_errors'
         8: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:25:in `block (2 levels) in perform'
         7: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:327:in `maybe_disable_triggers'
         6: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:26:in `block (3 levels) in perform'
         5: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:139:in `sync_data'
         4: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:221:in `copy'
         3: from /var/lib/gems/2.7.0/gems/pg-1.5.3/lib/pg/connection.rb:228:in `copy_data'
         2: from /var/lib/gems/2.7.0/gems/pgsync-0.7.4/lib/pgsync/task.rb:222:in `block in copy'
         1: from /var/lib/gems/2.7.0/gems/pg-1.5.3/lib/pg/connection.rb:213:in `copy_data'
/var/lib/gems/2.7.0/gems/pg-1.5.3/lib/pg/connection.rb:213:in `exec': ERROR:  column "updatedat" does not exist (PG::UndefinedColumn)
LINE 1: ..."."TestTable"."width" FROM "public"."TestTable" where updatedAt ...
                                                             ^
HINT:  Perhaps you meant to reference the column "TestTable.updatedAt".

This is the command I tried to use.

pgsync --config ./config.yml TestTable "where "updatedAt" > NOW() - INTERVAL '5 hours' "
ankane commented

Hi @JohnnyRacer, the quotes around updatedAt need to be escaped: \"updatedAt\"