Add ON DUPLICATE KEY UPDATE clause to pt-table-sync on inserts

Registered by DavidDucos on 2017-02-02

On subroutine make_row on ChangeHandler package, I created this patch:

--- /usr/bin/pt-table-sync 2016-08-15 14:36:04.000000000 +0000
+++ pt-table-sync 2017-02-02 22:33:21.753458680 +0000
@@ -3594,7 +3594,20 @@
                      is_float => $is_float,
                )
             } @cols)
- . ')';
+ . ')'.
+ .' ON DUPLICATE KEY UPDATE '
+ . join(', ',
+ map {
+ my $is_char = ($type_for->{$_} || '') =~ m/char|text|enum/i;
+ my $is_float = ($type_for->{$_} || '') =~ m/float|double/i;
+ $q->quote($_) .'='.
+ $q->quote_val(
+ $row->{$_},
+ is_char => $is_char,
+ is_float => $is_float,
+ )
+ } @cols)
+;
 }

 sub make_where_clause {

The problem with it, is that it adds the ON DUPLICATE KEY UPDATE on every single case, so we need to add an option, which should be false by default, so the user can add it or not.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
DavidDucos
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.