Skip to content

Commit

Permalink
Return error when creating with unaddressable record in postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Nov 4, 2016
1 parent d5d3e3a commit 9edd662
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions callback_create.go
Expand Up @@ -117,9 +117,13 @@ func createCallback(scope *Scope) {
}
}
} else {
if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil {
primaryField.IsBlank = false
scope.db.RowsAffected = 1
if primaryField.Field.CanAddr() {
if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil {
primaryField.IsBlank = false
scope.db.RowsAffected = 1
}
} else {
scope.Err(ErrUnaddressable)
}
}
}
Expand Down

0 comments on commit 9edd662

Please sign in to comment.