Compare commits

...
4 Commits
Author SHA1 Message Date
Dustin Pianalto 7a8e7bf213 use nullable string in user
CI / build (push) Has been cancelled
2021-01-23 16:05:02 -09:00
Dustin Pianalto 96e8388562 fix bug in user database
CI / build (push) Has been cancelled
2021-01-23 15:10:04 -09:00
Dustin Pianalto 6369f37ce5 fix bug in user service
CI / build (push) Has been cancelled
2021-01-23 15:03:15 -09:00
Dustin Pianalto ab2d51c582 fix bug in user service
CI / build (push) Has been cancelled
2021-01-23 14:59:35 -09:00
2 changed files with 3 additions and 6 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ func ConnectDatabase(dbConnString string) {
func(name string) ([]byte, error) {
return migrations.Asset(name)
})
db, err := sql.Open("postgres", dbConnString)
var err error
db, err = sql.Open("postgres", dbConnString)
if err != nil {
log.Fatal(fmt.Errorf("Can't connect to the database: %w", err))
}
+1 -5
View File
@@ -21,11 +21,7 @@ func (s userService) User(id string) (geeksbot.User, error) {
func (s userService) CreateUser(u geeksbot.User) (geeksbot.User, error) {
queryString := "INSERT INTO users (id, steam_id, active, staff, admin) VALUES ($1, $2, $3, $4, $5)"
var err error
if u.SteamID.Valid {
_, err = s.db.Exec(queryString, u.ID, u.SteamID.String, u.IsActive, u.IsStaff, u.IsAdmin)
} else {
_, err = s.db.Exec(queryString, u.ID, nil, u.IsActive, u.IsStaff, u.IsAdmin)
}
_, err = s.db.Exec(queryString, u.ID, u.SteamID, u.IsActive, u.IsStaff, u.IsAdmin)
return u, err
}