ValidateNewTableName implements the sql.SchemaObjectNameValidator interface
(ctx *sql.Context, newTableName string, skipIfExists bool)
| 244 | |
| 245 | // ValidateNewTableName implements the sql.SchemaObjectNameValidator interface |
| 246 | func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error) { |
| 247 | relationExists, _, err := d.doesRelationExist(ctx, newTableName) |
| 248 | if err != nil { |
| 249 | return false, err |
| 250 | } |
| 251 | |
| 252 | if !relationExists { |
| 253 | return false, nil |
| 254 | } |
| 255 | |
| 256 | if skipIfExists { |
| 257 | return true, nil |
| 258 | } |
| 259 | |
| 260 | return true, fmt.Errorf(`relation "%s" already exists`, newTableName) |
| 261 | } |
| 262 | |
| 263 | // GenerateIndexName implements the sql.IndexNameGenerator interface with PostgreSQL-compatible naming conventions: |
| 264 | // - UNIQUE indexes: <table>_<col1>[_col2...]_key |
nothing calls this directly
no test coverage detected