execSQL executes SQL within a transaction, either as a single exec or split by statements
(ctx context.Context, tx *sql.Tx, query string)
| 46 | |
| 47 | // execSQL executes SQL within a transaction, either as a single exec or split by statements |
| 48 | func (s SQLMigration) execSQL(ctx context.Context, tx *sql.Tx, query string) error { |
| 49 | if !s.splitStatements { |
| 50 | _, err := tx.ExecContext(ctx, query) |
| 51 | return err |
| 52 | } |
| 53 | |
| 54 | statements := splitSQLStatementsWithAnnotations(query) |
| 55 | for _, stmt := range statements { |
| 56 | if _, err := tx.ExecContext(ctx, stmt); err != nil { |
| 57 | return err |
| 58 | } |
| 59 | } |
| 60 | return nil |
| 61 | } |
| 62 | |
| 63 | // execSQLDB executes SQL on a DB, either as a single exec or split by statements |
| 64 | func (s SQLMigration) execSQLDB(ctx context.Context, db *sql.DB, query string) error { |
no test coverage detected