Don't use LastInsertId() with postgres
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2021-10-31 02:03:38 +02:00
parent f83970446e
commit 4f6ea0efb2
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -319,15 +319,16 @@ func (b *memoryBackend) FollowURL(uid string, url string) (microsub.Feed, error)
} }
} }
result, err := b.database.Exec( row := b.database.QueryRow(
`INSERT INTO "feeds" ("channel_id", "url") VALUES ($1, $2)`, `INSERT INTO "feeds" ("channel_id", "url") VALUES ($1, $2) RETURNING "id"`,
channelID, channelID,
feed.URL, feed.URL,
) )
if err != nil { if row == nil {
return microsub.Feed{}, err return microsub.Feed{}, fmt.Errorf("no feed_id")
} }
feedID, _ := result.LastInsertId() var feedID int
_ = row.Scan(&feedID)
resp, err := b.Fetch3(uid, feed.URL) resp, err := b.Fetch3(uid, feed.URL)
if err != nil { if err != nil {