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

Function TestBackupStatementStructure

backend/plugin/parser/tsql/backup_test.go:193–213  ·  view source on GitHub ↗

TestBackupStatementStructure validates the structure of backup statements

(t *testing.T)

Source from the content-addressed store, hash-verified

191
192// TestBackupStatementStructure validates the structure of backup statements
193func TestBackupStatementStructure(t *testing.T) {
194 a := require.New(t)
195
196 // Test that UPDATE statements generate correct backup SQL
197 input := `UPDATE employees SET salary = salary * 1.1 WHERE department_id = 5;`
198
199 result, err := TransformDMLToSelect(context.Background(), base.TransformContext{},
200 input, "production", "backup", "migration")
201 a.NoError(err)
202 a.Len(result, 1)
203
204 backupStmt := result[0]
205
206 // Verify backup statement metadata
207 a.Equal("dbo", backupStmt.SourceSchema)
208 a.Equal("employees", backupStmt.SourceTableName)
209 a.Equal("migration_employees_production", backupStmt.TargetTableName)
210
211 // Verify the SQL structure handles the WHERE clause properly
212 a.Contains(backupStmt.Statement, "WHERE department_id = 5")
213}
214
215// TestBackupWithQuotedStrings validates that single quotes in WHERE clauses are properly handled
216func TestBackupWithQuotedStrings(t *testing.T) {

Callers

nothing calls this directly

Calls 3

LenMethod · 0.80
TransformDMLToSelectFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected