ValidateNewViewName implements the sql.SchemaObjectNameValidator interface
(ctx *sql.Context, newViewName string, replaceAllowed bool)
| 221 | |
| 222 | // ValidateNewViewName implements the sql.SchemaObjectNameValidator interface |
| 223 | func (d *PgDatabase) ValidateNewViewName(ctx *sql.Context, newViewName string, replaceAllowed bool) error { |
| 224 | relationExists, relationType, err := d.doesRelationExist(ctx, newViewName) |
| 225 | if err != nil { |
| 226 | return err |
| 227 | } |
| 228 | |
| 229 | if !relationExists { |
| 230 | return nil |
| 231 | } |
| 232 | |
| 233 | // When REPLACE is used, Postgres sends a different error message |
| 234 | if replaceAllowed { |
| 235 | if relationType == "view" { |
| 236 | return nil |
| 237 | } else { |
| 238 | return fmt.Errorf(`"%s" is not a view`, newViewName) |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return fmt.Errorf(`relation "%s" already exists`, newViewName) |
| 243 | } |
| 244 | |
| 245 | // ValidateNewTableName implements the sql.SchemaObjectNameValidator interface |
| 246 | func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error) { |
nothing calls this directly
no test coverage detected