Should fix cascading delete issue (#3)
continuous-integration/drone/push Build is passing Details

Reviewed-on: #3
Co-authored-by: Ezri Brimhall <ezri.brimhall@usu.edu>
Co-committed-by: Ezri Brimhall <ezri.brimhall@usu.edu>
This commit is contained in:
Ezri Brimhall 2024-04-02 14:55:22 -04:00 committed by simponic
parent eccc0f20f0
commit eb1a6069d6
1 changed files with 6 additions and 1 deletions

View File

@ -50,7 +50,12 @@ func GetUser(dbConn *sql.DB, id string) (*User, error) {
func FindOrSaveUser(dbConn *sql.DB, user *User) (*User, error) { func FindOrSaveUser(dbConn *sql.DB, user *User) (*User, error) {
log.Println("finding or saving user", user.ID) log.Println("finding or saving user", user.ID)
_, err := dbConn.Exec(`INSERT OR REPLACE INTO users (id, mail, username, display_name) VALUES (?, ?, ?, ?);`, user.ID, user.Mail, user.Username, user.DisplayName) _, err := dbConn.Exec(`INSERT OR IGNORE INTO users (id, mail, username, display_name) VALUES (?, ?, ?, ?);`, user.ID, user.Mail, user.Username, user.DisplayName)
if err != nil {
return nil, err
}
_, err = dbConn.Exec(`UPDATE users SET mail = ?, username = ?, display_name = ? WHERE id = ?;`, user.Mail, user.Username, user.DisplayName, user.ID)
if err != nil { if err != nil {
return nil, err return nil, err
} }