Skip to content

Commit

Permalink
fix mssql adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusheine committed Dec 11, 2023
1 parent 2192c6b commit de7de10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions adapters/mssql_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func (adapter mssqlAdapter) DeleteDatabase(ctx context.Context, database string)
}

func (adapter mssqlAdapter) HasDatabaseUserWithAccess(ctx context.Context, database string, username string) (bool, error) {
dbExists, dbExistsErr := adapter.HasDatabase(ctx, database)
if dbExistsErr != nil {
return false, dbExistsErr
}
if !dbExists {
return false, nil
}

var count int
query := fmt.Sprintf("USE [%s]; SELECT COUNT(*) FROM sys.database_principals WHERE authentication_type=2 AND name='%s';", database, username)
err := adapter.db.QueryRowContext(ctx, query).Scan(&count)
Expand Down

0 comments on commit de7de10

Please sign in to comment.