Explorar el Código

Clickhouse

- refactoring
Alexey Kim hace 8 meses
padre
commit
58eebc7847
Se han modificado 1 ficheros con 3 adiciones y 11 borrados
  1. 3 11
      database/clickhouse.go

+ 3 - 11
database/clickhouse.go

@@ -91,6 +91,7 @@ func (db *_ch) Query(ctx context.Context, query string, args ...any) (driver.Row
 	return db.conn.Query(ctx, query, args...)
 }
 
+//goland:noinspection SqlNoDataSourceInspection
 func (db *_ch) Batch(ctx context.Context, table string, release bool) (driver.Batch, error) {
 	table = strings.TrimSpace(table)
 	if table == "" {
@@ -98,22 +99,13 @@ func (db *_ch) Batch(ctx context.Context, table string, release bool) (driver.Ba
 	}
 
 	var (
-		batch driver.Batch
+		query = fmt.Sprintf("INSERT INTO `%s`", table)
 		opts  []driver.PrepareBatchOption
-		err   error
 	)
 
 	if release {
 		opts = append(opts, driver.WithReleaseConnection())
 	}
 
-	if //goland:noinspection SqlNoDataSourceInspection
-	batch, err = db.conn.PrepareBatch(ctx,
-		fmt.Sprintf("INSERT INTO `%s`", table),
-		opts...,
-	); err != nil {
-		return nil, err
-	}
-
-	return batch, nil
+	return db.conn.PrepareBatch(ctx, query, opts...)
 }