Skip to content

Commit

Permalink
clichouse create user query update
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Nov 27, 2023
1 parent fad7d61 commit fe6cf27
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions db/dialect_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,25 @@ func (d clickhouseDialect) OnlyInserts() bool {

func (d clickhouseDialect) CreateUser(tx Tx, ctx context.Context, l *Loader, username string, password string, _database string, readOnly bool) error {
user, pass := EscapeIdentifier(username), EscapeIdentifier(password)

Check failure on line 135 in db/dialect_clickhouse.go

View workflow job for this annotation

GitHub Actions / build-vanilla (1.20.x)

pass declared and not used
var q string

createUserQ := "CREATE USER %s IDENTIFIED BY '%s';"
_, err := tx.ExecContext(ctx, createUserQ)
if err != nil {
return fmt.Errorf("executing query %q: %w", q, err)

Check failure on line 140 in db/dialect_clickhouse.go

View workflow job for this annotation

GitHub Actions / build-vanilla (1.20.x)

undefined: q
}

var grantQ string
if readOnly {
q = fmt.Sprintf(`
CREATE USER %s IDENTIFIED BY '%s';
grantQ = fmt.Sprintf(`
GRANT SELECT ON *.* TO %s;
`, user, pass, user)
`, user)
} else {
q = fmt.Sprintf(`
CREATE USER %s IDENTIFIED BY '%s';
grantQ = fmt.Sprintf(`
GRANT ALL ON *.* TO %s;
`, user, pass, user)
`, user)
}

_, err := tx.ExecContext(ctx, q)
_, err = tx.ExecContext(ctx, grantQ)
if err != nil {
return fmt.Errorf("executing query %q: %w", q, err)

Check failure on line 156 in db/dialect_clickhouse.go

View workflow job for this annotation

GitHub Actions / build-vanilla (1.20.x)

undefined: q
}
Expand Down

0 comments on commit fe6cf27

Please sign in to comment.