Skip to content

Commit

Permalink
Add merge to qtag instances in builder (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
rymurr authored Aug 7, 2024
1 parent ddaf67e commit 8d1dead
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/cmd/declarations/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func (c *{{.ClassName}}) Format() (string, error) {
func (c *{{.ClassName}}) UnknownValue(name string, value any) {
c.values[name] = value
}
func (c *{{.ClassName}}) Merge(other *{{.ClassName}}) {
for k, v := range other.values {
c.values[k] = v
}
}
`

// Template for generating methods
Expand Down
13 changes: 13 additions & 0 deletions go/pkg/qtag/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ func TestInit(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, `{"app":"dbt","connection_name":"x"}`, s)
}

func TestMerge(t *testing.T) {
var x = NewDbt()
x.AddConnection_name("x")
x.AddNode_id("bob")
var y = NewDbt()
y.AddConnection_name("xx")
y.AddIs_incremental(false)
x.Merge(y)
s, err := x.Format()
assert.NoError(t, err)
assert.Equal(t, `{"app":"dbt","connection_name":"xx","is_incremental":false,"node_id":"bob"}`, s)
}
56 changes: 56 additions & 0 deletions go/pkg/qtag/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func (c *Dbt) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Dbt) Merge(other *Dbt) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Dbt) AddApp(value any) {
c.values["app"] = value
}
Expand Down Expand Up @@ -164,6 +170,12 @@ func (c *Hex) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Hex) Merge(other *Hex) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Hex) AddCategories(value any) {
c.values["categories"] = value
}
Expand Down Expand Up @@ -220,6 +232,12 @@ func (c *Metabase) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Metabase) Merge(other *Metabase) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Metabase) AddClient(value any) {
c.values["client"] = value
}
Expand Down Expand Up @@ -288,6 +306,12 @@ func (c *Mode) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Mode) Merge(other *Mode) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Mode) AddUser(value any) {
c.values["user"] = value
}
Expand Down Expand Up @@ -332,6 +356,12 @@ func (c *Sigma) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Sigma) Merge(other *Sigma) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Sigma) AddKind(value any) {
c.values["kind"] = value
}
Expand Down Expand Up @@ -376,6 +406,12 @@ func (c *Sundeck) UnknownValue(name string, value any) {
c.values[name] = value
}

func (c *Sundeck) Merge(other *Sundeck) {
for k, v := range other.values {
c.values[k] = v
}
}

func (c *Sundeck) AddApp(value any) {
c.values["app"] = value
}
Expand Down Expand Up @@ -435,3 +471,23 @@ func (c *Sundeck) AddWorkload(value any) {
func (c *Sundeck) AddKind(value any) {
c.values["kind"] = value
}

func (c *Sundeck) AddAuto_routing_matched(value any) {
c.values["auto_routing_matched"] = value
}

func (c *Sundeck) AddAuto_routing_matched_warehouse(value any) {
c.values["auto_routing_matched_warehouse"] = value
}

func (c *Sundeck) AddAuto_routing_matched_warehouse_size(value any) {
c.values["auto_routing_matched_warehouse_size"] = value
}

func (c *Sundeck) AddAuto_routing_num_computed_signatures(value any) {
c.values["auto_routing_num_computed_signatures"] = value
}

func (c *Sundeck) AddAuto_routing_warehouse_pool(value any) {
c.values["auto_routing_warehouse_pool"] = value
}

0 comments on commit 8d1dead

Please sign in to comment.