diff --git a/repository/paste.go b/repository/paste.go index f21a7d1..91d8807 100644 --- a/repository/paste.go +++ b/repository/paste.go @@ -34,13 +34,14 @@ func (db *DatabaseConnector) PutPaste(title string) (Paste, error) { return Paste{}, err } - insertResult, err := db.DB.Exec("INSERT INTO paste VALUES(DEFAULT, $1, $2)", title, handle.String()) + insertResult := db.DB.QueryRow("INSERT INTO paste VALUES(DEFAULT, $1, $2) RETURNING pasteID", title, handle.String()) + + var pasteID int + err = insertResult.Scan(&pasteID) if err != nil { return Paste{}, err } - pasteID, err := insertResult.LastInsertId() - return Paste{ // Even though pasteID is an int64, Postgres' SERIAL is 32 bits, and int is defined to be >= 32 bits ID: int(pasteID),