Merge remote-tracking branch 'origin/master'
Use a more efficient query when inserting with an existing key. This will break polymodel support but we should do that with query manipulation (or skip inserts of the basemodel in that case)