TestBackupStatementStructure validates the structure of backup statements
(t *testing.T)
| 191 | |
| 192 | // TestBackupStatementStructure validates the structure of backup statements |
| 193 | func 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 |
| 216 | func TestBackupWithQuotedStrings(t *testing.T) { |
nothing calls this directly
no test coverage detected