Fix SQLMergeClause keys handling

Fixes #940 
The only comment I have is that the templates are retrieved from the configuration, only to recreate the configuration in the updateclause. Is this intentional or does it otherwise have side effects?