Skip to content

Commit 34b1960

Browse files
PR feedback
1 parent 959ab9e commit 34b1960

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

bats/compatibility/runner.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash
22

3-
if [[ $(git diff --stat) != '' ]]; then
4-
echo "cannot run compatibility tests with git working changes"
5-
exit
6-
fi
7-
83
function build_dolt() {
94
pushd "$dolt_dir" > /dev/null || exit
105
git checkout "$1" > /dev/null
@@ -31,6 +26,11 @@ function run_bats_tests() {
3126
popd > /dev/null || exit
3227
}
3328

29+
# ensure that we have a clean working change set before we begin
30+
if [[ $(git diff --stat) != '' ]]; then
31+
echo "cannot run compatibility tests with git working changes"
32+
exit
33+
fi
3434

3535
# copy all the test files to take them out of source control
3636
# when we checkout different Dolt releases we don't want to

go/libraries/doltcore/schema/encoding/schema_marshaling.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// Correct Marshalling & Unmarshalling is essential to compatibility across Dolt versions
2929
// any changes to the fields of Schema or other persisted objects must be append only, no
30-
// fields can ever be removed without break compatibility.
30+
// fields can ever be removed without breaking compatibility.
3131
//
3232
// the marshalling annotations of new fields must have the "omitempty" option to allow newer
3333
// versions of Dolt to read objects serialized by older Dolt versions where the field did not
@@ -46,6 +46,8 @@ type encodedColumn struct {
4646
TypeInfo encodedTypeInfo `noms:"typeinfo,omitempty" json:"typeinfo,omitempty"`
4747

4848
Constraints []encodedConstraint `noms:"col_constraints" json:"col_constraints"`
49+
50+
// NB: all new fields must have the 'omitempty' annotation. See comment above
4951
}
5052

5153
func encodeAllColConstraints(constraints []schema.ColConstraint) []encodedConstraint {
@@ -80,7 +82,8 @@ func encodeColumn(col schema.Column) encodedColumn {
8082
col.KindString(),
8183
col.IsPartOfPK,
8284
encodeTypeInfo(col.TypeInfo),
83-
encodeAllColConstraints(col.Constraints)}
85+
encodeAllColConstraints(col.Constraints),
86+
}
8487
}
8588

8689
func (nfd encodedColumn) decodeColumn() (schema.Column, error) {

go/libraries/doltcore/schema/encoding/schema_marshaling_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestNomsMarshalling(t *testing.T) {
7474
validated, err := validateUnmarshaledNomsValue(context.Background(), types.Format_7_18, val)
7575

7676
if err != nil {
77-
t.Fatal("Failed compatibility test")
77+
t.Fatal("Failed compatibility test. Schema could not be unmarshalled with mirror type")
7878
}
7979

8080
if !reflect.DeepEqual(tSchema, validated) {
@@ -186,9 +186,22 @@ func validateUnmarshaledNomsValue(ctx context.Context, nbf *types.NomsBinFormat,
186186
return sd.decodeSchema()
187187
}
188188

189+
func TestMirroredTypes(t *testing.T) {
190+
realType := reflect.ValueOf(&encodedColumn{}).Elem()
191+
mirrorType := reflect.ValueOf(&testEncodedColumn{}).Elem()
192+
require.Equal(t, mirrorType.NumField(), realType.NumField())
193+
194+
// TODO: create reflection tests to ensure that:
195+
// - no fields in testEncodeColumn have the 'omitempty' annotation
196+
// - no legacy fields in encodeColumn have the 'omitempty' annotation (with whitelist)
197+
// - all new fields in encodeColumn have the 'omitempty' annotation
198+
}
199+
189200
// testEncodedColumn is a mirror type of encodedColumn that helps ensure compatibility between Dolt versions
190-
// fields in this test struct should be added WITHOUT the "omitempty" annotation in order to guarentee that
191-
// all fields are being always being written when encodedColumn is serialized.
201+
//
202+
// Fields in this test struct should be added WITHOUT the "omitempty" annotation in order to guarantee that
203+
// all fields in encodeColumn are always being written when encodedColumn is serialized.
204+
// See the comment above type encodeColumn.
192205
type testEncodedColumn struct {
193206
Tag uint64 `noms:"tag" json:"tag"`
194207

0 commit comments

Comments
 (0)