Skip to content

Commit

Permalink
create user 'if not exist' in clickhouse
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Nov 27, 2023
1 parent 5055727 commit f26a242
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion db/dialect_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ 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)

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

0 comments on commit f26a242

Please sign in to comment.