Query supports multi-insert with optional on duplicate update

Anthony @regeda, take a look