Skip to content

Commit

Permalink
Fix: diff OR primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Apr 23, 2024
1 parent b1b3a06 commit e3d90eb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/go-playground/validator/v10 v10.15.5
github.com/go-testfixtures/testfixtures/v3 v3.9.0
github.com/google/uuid v1.3.0
github.com/grafana/pyroscope-go v1.0.3
github.com/grafana/pyroscope-go v1.1.1
github.com/iancoleman/strcase v0.3.0
github.com/ipfs/go-cid v0.3.2
github.com/jessevdk/go-flags v1.5.0
Expand Down Expand Up @@ -79,15 +79,15 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.4 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/karlseguin/expect v1.0.8 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/grafana/pyroscope-go v1.0.3 h1:8WWmItzLfg4m8G+j//ElSjMeMr88Y6Lvblar6qeTyKk=
github.com/grafana/pyroscope-go v1.0.3/go.mod h1:0d7ftwSMBV/Awm7CCiYmHQEG8Y44Ma3YSjt+nWcWztY=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 h1:mDsJ3ngul7UfrHibGQpV66PbZ3q1T8glz/tK3bQKKEk=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko=
github.com/grafana/pyroscope-go v1.1.1 h1:PQoUU9oWtO3ve/fgIiklYuGilvsm8qaGhlY4Vw6MAcQ=
github.com/grafana/pyroscope-go v1.1.1/go.mod h1:Mw26jU7jsL/KStNSGGuuVYdUq7Qghem5P8aXYXSXG88=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand Down Expand Up @@ -226,8 +226,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
Expand Down
4 changes: 2 additions & 2 deletions internal/bcd/ast/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ func TestTypedAst_Diff(t *testing.T) {
tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`,
curr: `{"prim":"Left","args":[{"int":"10"}]}`,
prev: `{"prim":"Right","args":[{"string":"test"}]}`,
want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"string","type":"string","name":"@string_3","diff_type":"update","value":"test"}]}`,
want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"int","type":"int","name":"@int_2","diff_type":"update","value":"10"}]}`,
}, {
name: "or test",
tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`,
Expand All @@ -1118,7 +1118,7 @@ func TestTypedAst_Diff(t *testing.T) {
tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`,
curr: `{"prim":"Right","args":[{"string":"test"}]}`,
prev: `{"prim":"Left","args":[{"int":"0"}]}`,
want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"int","type":"int","name":"@int_2","diff_type":"update","value":"0"}]}`,
want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"string","type":"string","name":"@string_3","diff_type":"update","value":"test"}]}`,
}, {
name: "or test",
tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`,
Expand Down
3 changes: 3 additions & 0 deletions internal/bcd/ast/miguel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func (node *MiguelNode) print(depth int) string {
if node.Value != nil {
s.WriteString(fmt.Sprintf(" value=%v", node.Value))
}
if node.DiffType != "" {
s.WriteString(fmt.Sprintf(" diff_type=%v", node.DiffType))
}
s.WriteByte('\n')
for i := range node.Children {
s.WriteString(node.Children[i].print(depth + 1))
Expand Down
4 changes: 2 additions & 2 deletions internal/bcd/ast/or.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ func (or *Or) Distinguish(x Distinguishable) (*MiguelNode, error) {
case or.key == 0 && second.key == 0:
default:
if second.key == rightKey {
child, err := second.RightType.ToMiguel()
child, err := or.LeftType.ToMiguel()
if err != nil {
return nil, err
}
node.Children = append(node.Children, child)
node.setDiffType(MiguelKindUpdate)
}
if second.key == leftKey {
child, err := second.LeftType.ToMiguel()
child, err := or.RightType.ToMiguel()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e3d90eb

Please sign in to comment.