Skip to content

Commit

Permalink
less diff with helper
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed May 20, 2024
1 parent 3b457df commit 7120d2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
5 changes: 5 additions & 0 deletions pkg/sdk/snowflakesql/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ func (n Bool) Value() (driver.Value, error) {
}
return n.Bool, nil
}

// BoolValue returns either the default bool (false) if the Bool.Valid != true, of the underlying Bool.Value.
func (n Bool) BoolValue() bool {
return n.Valid && n.Bool
}
24 changes: 6 additions & 18 deletions pkg/sdk/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ func (row userDBRow) convert() *User {
Name: row.Name,
CreatedOn: row.CreatedOn,
LoginName: row.LoginName,
Disabled: row.Disabled.BoolValue(),
MustChangePassword: row.MustChangePassword.BoolValue(),
SnowflakeLock: row.SnowflakeLock.BoolValue(),
DefaultNamespace: row.DefaultNamespace,
DefaultRole: row.DefaultRole,
DefaultSecondaryRoles: row.DefaultSecondaryRoles,
ExtAuthnDuo: row.ExtAuthnDuo.BoolValue(),
ExtAuthnUid: row.ExtAuthnUid,
MinsToBypassMfa: row.MinsToBypassMfa,
Owner: row.Owner,
HasPassword: row.HasPassword.BoolValue(),
HasRsaPublicKey: row.HasRsaPublicKey.BoolValue(),
}
if row.DisplayName.Valid {
user.DisplayName = row.DisplayName.String
Expand All @@ -123,21 +129,9 @@ func (row userDBRow) convert() *User {
if row.Comment.Valid {
user.Comment = row.Comment.String
}
if row.Disabled.Valid {
user.Disabled = row.Disabled.Bool
}
if row.MustChangePassword.Valid {
user.MustChangePassword = row.MustChangePassword.Bool
}
if row.SnowflakeLock.Valid {
user.SnowflakeLock = row.SnowflakeLock.Bool
}
if row.DefaultWarehouse.Valid {
user.DefaultWarehouse = row.DefaultWarehouse.String
}
if row.ExtAuthnDuo.Valid {
user.ExtAuthnDuo = row.ExtAuthnDuo.Bool
}
if row.LastSuccessLogin.Valid {
user.LastSuccessLogin = row.LastSuccessLogin.Time
}
Expand All @@ -147,12 +141,6 @@ func (row userDBRow) convert() *User {
if row.LockedUntilTime.Valid {
user.LockedUntilTime = row.LockedUntilTime.Time
}
if row.HasPassword.Valid {
user.HasPassword = row.HasPassword.Bool
}
if row.HasRsaPublicKey.Valid {
user.HasRsaPublicKey = row.HasRsaPublicKey.Bool
}
return user
}

Expand Down

0 comments on commit 7120d2e

Please sign in to comment.