From 62f3c31121aba520304b85746ea37e51dc70c9a7 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Wed, 4 Mar 2026 12:51:45 -0800 Subject: [PATCH 1/8] [fix] support delimiter --- internal/mhelp/run_sql.go | 22 ++++++++++++++- lsmysql/mysql_test.go | 53 +++++++++++++++++++++++++++++++++++++ lsmysql/singlestore_test.go | 9 +++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/internal/mhelp/run_sql.go b/internal/mhelp/run_sql.go index 739c89e..6655cf5 100644 --- a/internal/mhelp/run_sql.go +++ b/internal/mhelp/run_sql.go @@ -8,6 +8,7 @@ import ( "github.com/muir/libschema" "github.com/muir/libschema/classifysql" "github.com/muir/libschema/internal" + "github.com/muir/sqltoken" "github.com/pkg/errors" ) @@ -16,7 +17,26 @@ type CanExecContext interface { } func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statements classifysql.Statements, rowsAffected *int64, m libschema.Migration, d *libschema.Database) error { - for _, commandSQL := range statements.TokensList().Strings() { + for _, tokens := range statements.TokensList() { + tokens = tokens.Strip() + if len(tokens) == 0 { + continue + } + if tokens[0].Type == sqltoken.DelimiterStatement { + log.Debug("Stripping leading delimiter statement from migration", map[string]any{ + "name": m.Base().Name.Name, + "library": m.Base().Name.Library, + }) + tokens = tokens[1:] + } + if tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement { + log.Debug("Stripping trailing delimiter statement from migration", map[string]any{ + "name": m.Base().Name.Name, + "library": m.Base().Name.Library, + }) + tokens = tokens[:len(tokens)-1] + } + commandSQL := tokens.String() result, err := tx.ExecContext(ctx, commandSQL) if d.Options.DebugLogging { log.Debug("Executed SQL", map[string]any{ diff --git a/lsmysql/mysql_test.go b/lsmysql/mysql_test.go index cce14bf..237600b 100644 --- a/lsmysql/mysql_test.go +++ b/lsmysql/mysql_test.go @@ -273,3 +273,56 @@ func testMysqlNotAllowed(t *testing.T, dsn string, createPostfix string, driverN } } } + +func TestMysqlMigrationWithDelimiter(t *testing.T) { + t.Parallel() + dsn := os.Getenv("LIBSCHEMA_MYSQL_TEST_DSN") + if dsn == "" { + t.Skip("Set $LIBSCHEMA_MYSQL_TEST_DSN to test libschema/lsmysql") + } + testMigrationWithDelimiter(t, dsn, "ENGINE = InnoDB", mysqlNew) +} + +func testMigrationWithDelimiter(t *testing.T, dsn string, createPostfix string, driverNew driverNew) { + options, cleanup := lstesting.FakeSchema(t, "") + + t.Log("Doing migrations in database/schema", options.SchemaOverride) + + t.Log("We will error on unknown migrations") + + options.DebugLogging = true + t.Log("No opening the database...") + db, err := sql.Open("mysql", dsn) + require.NoError(t, err, "open database") + defer func() { + assert.NoError(t, db.Close()) + }() + defer cleanup(db) + + s := libschema.New(context.Background(), options) + dbase, _, err := driverNew(t, "test", s, db) + require.NoError(t, err, "libschema NewDatabase") + + dbase.Migrations("L1", + lsmysql.Script("SP", ` +DELIMITER // +CREATE PROCEDURE charge_account(id BIGINT, amount DECIMAL(18,4)) AS + DECLARE + balance_tbl QUERY(bal DECIMAL(18,4)) = + SELECT remaining_balance + FROM account_balance + WHERE account_id = id; + balance DECIMAL(18,4) = SCALAR(balance_tbl); + updated_balance DECIMAL(18,4) = balance - amount; + BEGIN + IF balance > amount THEN + UPDATE account_balance + SET remaining_balance = updated_balance + WHERE account_id = id; + END IF; + END // +DELIMITER ; +`)) + err = s.Migrate(context.Background()) + assert.NoError(t, err) +} diff --git a/lsmysql/singlestore_test.go b/lsmysql/singlestore_test.go index bada3f9..516fd89 100644 --- a/lsmysql/singlestore_test.go +++ b/lsmysql/singlestore_test.go @@ -60,6 +60,15 @@ func TestSingleStoreNotAllowed(t *testing.T) { testMysqlNotAllowed(t, dsn, "", singleStoreNew) } +func TestSingleStoreMigrationWithDelimiter(t *testing.T) { + t.Parallel() + dsn := os.Getenv("LIBSCHEMA_SINGLESTORE_TEST_DSN") + if dsn == "" { + t.Skip("Set $LIBSCHEMA_SINGLESTORE_TEST_DSN to test SingleStore support in libschema/lsmysql") + } + testMigrationWithDelimiter(t, dsn, "", singleStoreNew) +} + func TestSingleStoreFailedMigration(t *testing.T) { t.Parallel() dsn := os.Getenv("LIBSCHEMA_SINGLESTORE_TEST_DSN") From 45b03224bdcc7d5ad078369b38e64a0f5443f2b4 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Thu, 5 Mar 2026 16:11:50 -0800 Subject: [PATCH 2/8] add preservecomments --- api.go | 13 +++++++++++++ internal/mhelp/run_sql.go | 4 +++- lspostgres/bad_test.go | 2 +- lspostgres/non_tx_test.go | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index 253a587..128ae3c 100644 --- a/api.go +++ b/api.go @@ -74,6 +74,7 @@ type MigrationBase struct { nonTransactional bool // set automatically or by ForceNonTransactional / inference forcedTx *bool // if not nil, explicitly chosen transactional mode (true=transactional, false=non-transactional) notes map[string]any + preserveComments bool } func (m MigrationBase) Copy() MigrationBase { @@ -328,6 +329,15 @@ func ForceTransactional() MigrationOption { } } +// PreserveComments prevents stripping of SQL comments before execution. +// This is primarily useful for testing scenarios where comment-only +// statements are needed to exercise specific code paths. +func PreserveComments() MigrationOption { + return func(m Migration) { + m.Base().preserveComments = true + } +} + // ApplyForceOverride overrides transactionality for any prior force call (ForceTransactional // or ForceNonTransactional) func (m *MigrationBase) ApplyForceOverride() { @@ -416,6 +426,9 @@ func (m *MigrationBase) ForcedTransactional() bool { return m.forcedTx != nil && // ForcedNonTransactional reports if ForceNonTransactional() was explicitly called. func (m *MigrationBase) ForcedNonTransactional() bool { return m.forcedTx != nil && !*m.forcedTx } +// PreserveComments reports if PreserveComments() was set on this migration. +func (m *MigrationBase) PreserveComments() bool { return m.preserveComments } + func (n MigrationName) String() string { return n.Library + ": " + n.Name } diff --git a/internal/mhelp/run_sql.go b/internal/mhelp/run_sql.go index 6655cf5..2697c72 100644 --- a/internal/mhelp/run_sql.go +++ b/internal/mhelp/run_sql.go @@ -18,7 +18,9 @@ type CanExecContext interface { func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statements classifysql.Statements, rowsAffected *int64, m libschema.Migration, d *libschema.Database) error { for _, tokens := range statements.TokensList() { - tokens = tokens.Strip() + if !m.Base().PreserveComments() { + tokens = tokens.Strip() + } if len(tokens) == 0 { continue } diff --git a/lspostgres/bad_test.go b/lspostgres/bad_test.go index 29b5aec..b175c50 100644 --- a/lspostgres/bad_test.go +++ b/lspostgres/bad_test.go @@ -121,7 +121,7 @@ func TestBadMigrationsPostgres(t *testing.T) { define: func(dbase *libschema.Database) { dbase.Migrations("L9", lspostgres.Script("T4", `CREATE TABLE T1 (id text)`), - lspostgres.Script("T5", ` -- just a comment`, libschema.RepeatUntilNoOp()), + lspostgres.Script("T5", ` -- just a comment`, libschema.RepeatUntilNoOp(), libschema.PreserveComments()), ) }, }, diff --git a/lspostgres/non_tx_test.go b/lspostgres/non_tx_test.go index 451f069..f4997c2 100644 --- a/lspostgres/non_tx_test.go +++ b/lspostgres/non_tx_test.go @@ -217,7 +217,8 @@ func TestRowsAffectedErrorLogged(t *testing.T) { require.NoError(t, err) lib := fmt.Sprintf("RA_%d", time.Now().UnixNano()) comment := lspostgres.Script("NOTHING", - " -- just a comment") + " -- just a comment", + libschema.PreserveComments()) dbase.Migrations(lib, comment) require.NoError(t, s.Migrate(ctx)) entries := capLog.Entries() From 1b5496eac94ebd7ecf2b187ca54bd93298cbd006 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Thu, 5 Mar 2026 16:30:08 -0800 Subject: [PATCH 3/8] Update lsmysql/mysql_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lsmysql/mysql_test.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lsmysql/mysql_test.go b/lsmysql/mysql_test.go index 237600b..8433fe5 100644 --- a/lsmysql/mysql_test.go +++ b/lsmysql/mysql_test.go @@ -306,21 +306,18 @@ func testMigrationWithDelimiter(t *testing.T, dsn string, createPostfix string, dbase.Migrations("L1", lsmysql.Script("SP", ` DELIMITER // -CREATE PROCEDURE charge_account(id BIGINT, amount DECIMAL(18,4)) AS - DECLARE - balance_tbl QUERY(bal DECIMAL(18,4)) = - SELECT remaining_balance - FROM account_balance - WHERE account_id = id; - balance DECIMAL(18,4) = SCALAR(balance_tbl); - updated_balance DECIMAL(18,4) = balance - amount; - BEGIN - IF balance > amount THEN - UPDATE account_balance - SET remaining_balance = updated_balance - WHERE account_id = id; - END IF; - END // +CREATE PROCEDURE charge_account(IN id BIGINT, IN amount DECIMAL(18,4)) +BEGIN + DECLARE balance DECIMAL(18,4); + SELECT remaining_balance INTO balance + FROM account_balance + WHERE account_id = id; + IF balance > amount THEN + UPDATE account_balance + SET remaining_balance = balance - amount + WHERE account_id = id; + END IF; +END // DELIMITER ; `)) err = s.Migrate(context.Background()) From 2dbf0085d1774918ead9f57a1072deb8f0e0e5af Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Thu, 5 Mar 2026 16:11:50 -0800 Subject: [PATCH 4/8] add preservecomments --- internal/mhelp/run_sql.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/mhelp/run_sql.go b/internal/mhelp/run_sql.go index 2697c72..b0632b3 100644 --- a/internal/mhelp/run_sql.go +++ b/internal/mhelp/run_sql.go @@ -30,6 +30,9 @@ func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statement "library": m.Base().Name.Library, }) tokens = tokens[1:] + if len(tokens) == 0 { + continue + } } if tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement { log.Debug("Stripping trailing delimiter statement from migration", map[string]any{ @@ -37,6 +40,9 @@ func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statement "library": m.Base().Name.Library, }) tokens = tokens[:len(tokens)-1] + if len(tokens) == 0 { + continue + } } commandSQL := tokens.String() result, err := tx.ExecContext(ctx, commandSQL) From 34dc16381d4fae3ec4eb79ff03fe618d33372745 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Thu, 5 Mar 2026 17:26:05 -0800 Subject: [PATCH 5/8] fix stripping --- internal/mhelp/run_sql.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/mhelp/run_sql.go b/internal/mhelp/run_sql.go index b0632b3..c6966f4 100644 --- a/internal/mhelp/run_sql.go +++ b/internal/mhelp/run_sql.go @@ -24,8 +24,10 @@ func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statement if len(tokens) == 0 { continue } + // Expected pattern: DelimiterStatement, stuff, Delimiter, optional DelimiterStatement + // Strip leading DelimiterStatement if tokens[0].Type == sqltoken.DelimiterStatement { - log.Debug("Stripping leading delimiter statement from migration", map[string]any{ + log.Debug("Stripping leading DelimiterStatement from migration", map[string]any{ "name": m.Base().Name.Name, "library": m.Base().Name.Library, }) @@ -34,8 +36,20 @@ func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statement continue } } + // Strip optional trailing DelimiterStatement if tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement { - log.Debug("Stripping trailing delimiter statement from migration", map[string]any{ + log.Debug("Stripping trailing DelimiterStatement from migration", map[string]any{ + "name": m.Base().Name.Name, + "library": m.Base().Name.Library, + }) + tokens = tokens[:len(tokens)-1] + if len(tokens) == 0 { + continue + } + } + // Strip trailing Delimiter + if tokens[len(tokens)-1].Type == sqltoken.Delimiter { + log.Debug("Stripping trailing Delimiter from migration", map[string]any{ "name": m.Base().Name.Name, "library": m.Base().Name.Library, }) From ea6946df13303b141977976f596719b4091b95d2 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Mon, 9 Mar 2026 15:55:15 -0700 Subject: [PATCH 6/8] adjust stripping and other fixes --- internal/mhelp/run_sql.go | 48 ++++++++++++++++--------------------- lsmysql/mysql.go | 6 ++--- lsmysql/mysql_test.go | 44 +++++++++++++++++----------------- lsmysql/singlestore_test.go | 14 ++++++++++- lspostgres/postgres.go | 6 ++--- 5 files changed, 62 insertions(+), 56 deletions(-) diff --git a/internal/mhelp/run_sql.go b/internal/mhelp/run_sql.go index c6966f4..c035af0 100644 --- a/internal/mhelp/run_sql.go +++ b/internal/mhelp/run_sql.go @@ -21,42 +21,36 @@ func RunSQL(ctx context.Context, log *internal.Log, tx CanExecContext, statement if !m.Base().PreserveComments() { tokens = tokens.Strip() } - if len(tokens) == 0 { - continue - } - // Expected pattern: DelimiterStatement, stuff, Delimiter, optional DelimiterStatement - // Strip leading DelimiterStatement - if tokens[0].Type == sqltoken.DelimiterStatement { + // Strip leading DelimiterStatement (e.g., "DELIMITER //\n") + if len(tokens) > 0 && tokens[0].Type == sqltoken.DelimiterStatement { log.Debug("Stripping leading DelimiterStatement from migration", map[string]any{ "name": m.Base().Name.Name, "library": m.Base().Name.Library, }) tokens = tokens[1:] - if len(tokens) == 0 { - continue - } } - // Strip optional trailing DelimiterStatement - if tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement { - log.Debug("Stripping trailing DelimiterStatement from migration", map[string]any{ - "name": m.Base().Name.Name, - "library": m.Base().Name.Library, - }) - tokens = tokens[:len(tokens)-1] - if len(tokens) == 0 { - continue + // Strip trailing DelimiterStatement (e.g., "DELIMITER ;\n") and any whitespace before it + for len(tokens) > 0 && (tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement || tokens[len(tokens)-1].Type == sqltoken.Whitespace) { + if tokens[len(tokens)-1].Type == sqltoken.DelimiterStatement { + log.Debug("Stripping trailing DelimiterStatement from migration", map[string]any{ + "name": m.Base().Name.Name, + "library": m.Base().Name.Library, + }) } - } - // Strip trailing Delimiter - if tokens[len(tokens)-1].Type == sqltoken.Delimiter { - log.Debug("Stripping trailing Delimiter from migration", map[string]any{ - "name": m.Base().Name.Name, - "library": m.Base().Name.Library, - }) tokens = tokens[:len(tokens)-1] - if len(tokens) == 0 { - continue + } + // Strip trailing Delimiter (e.g., "//") and any whitespace before it + for len(tokens) > 0 && (tokens[len(tokens)-1].Type == sqltoken.Delimiter || tokens[len(tokens)-1].Type == sqltoken.Whitespace) { + if tokens[len(tokens)-1].Type == sqltoken.Delimiter { + log.Debug("Stripping trailing Delimiter from migration", map[string]any{ + "name": m.Base().Name.Name, + "library": m.Base().Name.Library, + }) } + tokens = tokens[:len(tokens)-1] + } + if len(tokens) == 0 { + continue } commandSQL := tokens.String() result, err := tx.ExecContext(ctx, commandSQL) diff --git a/lsmysql/mysql.go b/lsmysql/mysql.go index a9255fa..81e7203 100644 --- a/lsmysql/mysql.go +++ b/lsmysql/mysql.go @@ -255,9 +255,9 @@ func (p *MySQL) DoOneMigration(ctx context.Context, log *internal.Log, d *libsch } sqlText = genSQL } - sqlText = strings.TrimSpace(sqlText) - m.Base().SetNote("sql", sqlText) - if sqlText == "" { + trimmedSQLText := strings.TrimSpace(sqlText) + m.Base().SetNote("sql", trimmedSQLText) + if trimmedSQLText == "" { return nil } statements, err := classifysql.ClassifyTokens(p.dialect, 0, sqlText) diff --git a/lsmysql/mysql_test.go b/lsmysql/mysql_test.go index 8433fe5..c59028c 100644 --- a/lsmysql/mysql_test.go +++ b/lsmysql/mysql_test.go @@ -280,18 +280,34 @@ func TestMysqlMigrationWithDelimiter(t *testing.T) { if dsn == "" { t.Skip("Set $LIBSCHEMA_MYSQL_TEST_DSN to test libschema/lsmysql") } - testMigrationWithDelimiter(t, dsn, "ENGINE = InnoDB", mysqlNew) + testMysqlOneMigration(t, dsn, ` +DELIMITER // +CREATE PROCEDURE charge_account(IN id BIGINT, IN amount DECIMAL(18,4)) +BEGIN + DECLARE balance DECIMAL(18,4); + SELECT remaining_balance INTO balance + FROM account_balance + WHERE account_id = id; + IF balance > amount THEN + UPDATE account_balance + SET remaining_balance = balance - amount + WHERE account_id = id; + END IF; +END // +DELIMITER ; +`) +} + +func testMysqlOneMigration(t *testing.T, dsn string, sqlText string) { + testOneMigration(t, dsn, sqlText, mysqlNew) } -func testMigrationWithDelimiter(t *testing.T, dsn string, createPostfix string, driverNew driverNew) { +func testOneMigration(t *testing.T, dsn string, sqlText string, driverNew driverNew) { options, cleanup := lstesting.FakeSchema(t, "") t.Log("Doing migrations in database/schema", options.SchemaOverride) - t.Log("We will error on unknown migrations") - options.DebugLogging = true - t.Log("No opening the database...") db, err := sql.Open("mysql", dsn) require.NoError(t, err, "open database") defer func() { @@ -303,23 +319,7 @@ func testMigrationWithDelimiter(t *testing.T, dsn string, createPostfix string, dbase, _, err := driverNew(t, "test", s, db) require.NoError(t, err, "libschema NewDatabase") - dbase.Migrations("L1", - lsmysql.Script("SP", ` -DELIMITER // -CREATE PROCEDURE charge_account(IN id BIGINT, IN amount DECIMAL(18,4)) -BEGIN - DECLARE balance DECIMAL(18,4); - SELECT remaining_balance INTO balance - FROM account_balance - WHERE account_id = id; - IF balance > amount THEN - UPDATE account_balance - SET remaining_balance = balance - amount - WHERE account_id = id; - END IF; -END // -DELIMITER ; -`)) + dbase.Migrations("L1", lsmysql.Script("M1", sqlText)) err = s.Migrate(context.Background()) assert.NoError(t, err) } diff --git a/lsmysql/singlestore_test.go b/lsmysql/singlestore_test.go index 516fd89..01334b2 100644 --- a/lsmysql/singlestore_test.go +++ b/lsmysql/singlestore_test.go @@ -66,7 +66,19 @@ func TestSingleStoreMigrationWithDelimiter(t *testing.T) { if dsn == "" { t.Skip("Set $LIBSCHEMA_SINGLESTORE_TEST_DSN to test SingleStore support in libschema/lsmysql") } - testMigrationWithDelimiter(t, dsn, "", singleStoreNew) + testSingleStoreOneMigration(t, dsn, ` +DELIMITER // +CREATE OR REPLACE PROCEDURE test_proc() +AS +BEGIN + ECHO SELECT 1; +END // +DELIMITER ; +`) +} + +func testSingleStoreOneMigration(t *testing.T, dsn string, sqlText string) { + testOneMigration(t, dsn, sqlText, singleStoreNew) } func TestSingleStoreFailedMigration(t *testing.T) { diff --git a/lspostgres/postgres.go b/lspostgres/postgres.go index 359ce19..7837be7 100644 --- a/lspostgres/postgres.go +++ b/lspostgres/postgres.go @@ -219,9 +219,9 @@ func (p *Postgres) DoOneMigration(ctx context.Context, log *internal.Log, d *lib } scriptSQL = sqlText } - scriptSQL = strings.TrimSpace(scriptSQL) - m.Base().SetNote("sql", scriptSQL) - if scriptSQL == "" { + trimmedScriptSQL := strings.TrimSpace(scriptSQL) + m.Base().SetNote("sql", trimmedScriptSQL) + if trimmedScriptSQL == "" { return nil } // Classification & downgrade via classifysql From 2ddf67a9f1670b74b9a79cf4195a2ce43fd597de Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Mon, 9 Mar 2026 16:07:52 -0700 Subject: [PATCH 7/8] copilot feedback --- api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api.go b/api.go index 128ae3c..fa8afa5 100644 --- a/api.go +++ b/api.go @@ -332,6 +332,8 @@ func ForceTransactional() MigrationOption { // PreserveComments prevents stripping of SQL comments before execution. // This is primarily useful for testing scenarios where comment-only // statements are needed to exercise specific code paths. +// PreserveComments can break DELIMITER handling so do not use in conjunction +// with SQL that includes DELIMITERs. func PreserveComments() MigrationOption { return func(m Migration) { m.Base().preserveComments = true From 18f1f2da0f5e8998fe7be18ae2b3050e1d4246a5 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Mon, 9 Mar 2026 16:11:47 -0700 Subject: [PATCH 8/8] LLM missing the point --- lsmysql/mysql_test.go | 14 +++++++------- lsmysql/singlestore_test.go | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lsmysql/mysql_test.go b/lsmysql/mysql_test.go index c59028c..fd612cc 100644 --- a/lsmysql/mysql_test.go +++ b/lsmysql/mysql_test.go @@ -275,12 +275,7 @@ func testMysqlNotAllowed(t *testing.T, dsn string, createPostfix string, driverN } func TestMysqlMigrationWithDelimiter(t *testing.T) { - t.Parallel() - dsn := os.Getenv("LIBSCHEMA_MYSQL_TEST_DSN") - if dsn == "" { - t.Skip("Set $LIBSCHEMA_MYSQL_TEST_DSN to test libschema/lsmysql") - } - testMysqlOneMigration(t, dsn, ` + testMysqlOneMigration(t, ` DELIMITER // CREATE PROCEDURE charge_account(IN id BIGINT, IN amount DECIMAL(18,4)) BEGIN @@ -298,7 +293,12 @@ DELIMITER ; `) } -func testMysqlOneMigration(t *testing.T, dsn string, sqlText string) { +func testMysqlOneMigration(t *testing.T, sqlText string) { + t.Parallel() + dsn := os.Getenv("LIBSCHEMA_MYSQL_TEST_DSN") + if dsn == "" { + t.Skip("Set $LIBSCHEMA_MYSQL_TEST_DSN to test libschema/lsmysql") + } testOneMigration(t, dsn, sqlText, mysqlNew) } diff --git a/lsmysql/singlestore_test.go b/lsmysql/singlestore_test.go index 01334b2..5c79f94 100644 --- a/lsmysql/singlestore_test.go +++ b/lsmysql/singlestore_test.go @@ -61,12 +61,7 @@ func TestSingleStoreNotAllowed(t *testing.T) { } func TestSingleStoreMigrationWithDelimiter(t *testing.T) { - t.Parallel() - dsn := os.Getenv("LIBSCHEMA_SINGLESTORE_TEST_DSN") - if dsn == "" { - t.Skip("Set $LIBSCHEMA_SINGLESTORE_TEST_DSN to test SingleStore support in libschema/lsmysql") - } - testSingleStoreOneMigration(t, dsn, ` + testSingleStoreOneMigration(t, ` DELIMITER // CREATE OR REPLACE PROCEDURE test_proc() AS @@ -77,7 +72,12 @@ DELIMITER ; `) } -func testSingleStoreOneMigration(t *testing.T, dsn string, sqlText string) { +func testSingleStoreOneMigration(t *testing.T, sqlText string) { + t.Parallel() + dsn := os.Getenv("LIBSCHEMA_SINGLESTORE_TEST_DSN") + if dsn == "" { + t.Skip("Set $LIBSCHEMA_SINGLESTORE_TEST_DSN to test SingleStore support in libschema/lsmysql") + } testOneMigration(t, dsn, sqlText, singleStoreNew) }