MCPcopy Create free account
hub / github.com/bytebase/bytebase / executeSQL

Function executeSQL

backend/plugin/schema/mssql/testutil_test.go:34–54  ·  view source on GitHub ↗

executeSQL executes SQL statements, handling GO separators

(ctx context.Context, driver db.Driver, sql string)

Source from the content-addressed store, hash-verified

32
33// executeSQL executes SQL statements, handling GO separators
34func executeSQL(ctx context.Context, driver db.Driver, sql string) error {
35 if strings.TrimSpace(sql) == "" {
36 return nil
37 }
38
39 // Split by GO statements (case insensitive)
40 statements := splitByGO(sql)
41
42 for i, stmt := range statements {
43 stmt = strings.TrimSpace(stmt)
44 if stmt == "" {
45 continue
46 }
47
48 if _, err := driver.Execute(ctx, stmt, db.ExecuteOptions{}); err != nil {
49 return errors.Wrapf(err, "failed to execute statement %d: %s", i+1, stmt)
50 }
51 }
52
53 return nil
54}
55
56// splitByGO splits SQL by GO statements (case insensitive) or by semicolons if no GO statements
57func splitByGO(sql string) []string {

Calls 2

splitByGOFunction · 0.85
ExecuteMethod · 0.65

Tested by

no test coverage detected