don't panic on failed table creation

The attempt to set the TrackExistence option for fields
happened before checking whether the field was created
successfully or not. Credit to Rachith for spotting this.
Bug was introduced with the TrackExistence stuff, but
we apparently never had a test case for invalid min/max
values.
This commit is contained in:
Seebs 2023-04-03 15:44:44 -05:00 committed by seebs
parent 2af417d5c2
commit c8c88ab0ee
3 changed files with 11 additions and 4 deletions

View file

@ -94,11 +94,11 @@ func (i *alterTableRowIter) Next(ctx context.Context) (types.Row, error) {
fos := i.columnDef.fos
fld, err := pilosa.FieldFromFieldOptions(fname, fos...)
// all newly created fields unconditionally have TrackExistence turned on.
fld.Options.TrackExistence = true
if err != nil {
return nil, err
}
// all newly created fields unconditionally have TrackExistence turned on.
fld.Options.TrackExistence = true
if err := i.planner.schemaAPI.CreateField(ctx, tname, fld); err != nil {
return nil, err

View file

@ -112,11 +112,11 @@ func (i *createTableRowIter) Next(ctx context.Context) (types.Row, error) {
for _, f := range i.columns {
fld, err := pilosa.FieldFromFieldOptions(dax.FieldName(f.name), f.fos...)
// We unconditionally turn on TrackExistence for all newly-created fields.
fld.Options.TrackExistence = true
if err != nil {
return nil, errors.Wrapf(err, "creating field from field options: %s", f.name)
}
// We unconditionally turn on TrackExistence for all newly-created fields.
fld.Options.TrackExistence = true
fields = append(fields, fld)
}

View file

@ -31,6 +31,13 @@ var createTable = TableTest{
),
ExpErr: "expected literal, found bad",
},
{
name: "minAboveMax",
SQLs: sqls(
"create table bar (_id id, i1 int min 20 max 19)",
),
ExpErr: "int field min cannot be greater than max",
},
{
name: "commentString",
SQLs: sqls(