Fixes https://github.com/jinzhu/gorm/issues/317
Merge pull request #318 from galeone/master

Fixes #317