Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Corrected naming in template context objects #242

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/db/postgres/transformers/column_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func (cc *ColumnContext) GetValue() (any, error) {
}

func (cc *ColumnContext) GetRawValue() (any, error) {
return cc.rc.GetColumnRawValue(cc.columnName)
return cc.rc.GetRawColumnValue(cc.columnName)
}

func (cc *ColumnContext) GetColumnValue(name string) (any, error) {
return cc.rc.GetColumnValue(name)
}

func (cc *ColumnContext) GetColumnRawValue(name string) (any, error) {
return cc.rc.GetColumnRawValue(name)
func (cc *ColumnContext) GetRawColumnValue(name string) (any, error) {
return cc.rc.GetRawColumnValue(name)
}

func (cc *ColumnContext) EncodeValue(v any) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/db/postgres/transformers/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func NewEmailTransformer(ctx context.Context, driver *toolkit.Driver, parameters
for _, c := range driver.Table.Columns {
funcMap[c.Name] = func(name string) func() (any, error) {
return func() (any, error) {
return rrctx.GetColumnRawValue(name)
return rrctx.GetRawColumnValue(name)
}
}(c.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/db/postgres/transformers/json_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func (jc *JsonContext) GetColumnValue(name string) (any, error) {
return jc.rc.GetColumnValue(name)
}

func (jc *JsonContext) GetColumnRawValue(name string) (any, error) {
return jc.rc.GetColumnRawValue(name)
func (jc *JsonContext) GetRawColumnValue(name string) (any, error) {
return jc.rc.GetRawColumnValue(name)
}

func (jc *JsonContext) EncodeValueByColumn(name string, v any) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/db/postgres/transformers/template_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestTemplateRecordTransformer_Transform_date(t *testing.T) {
func TestTemplateRecordTransformer_Transform_json(t *testing.T) {
var columnName = "doc"
var template = `
{{ $val := .GetColumnRawValue "doc" }}
{{ $val := .GetRawColumnValue "doc" }}
{{ jsonSet "name" "hello" $val | jsonValidate | .SetColumnValue "doc" }}
`

Expand Down
6 changes: 3 additions & 3 deletions pkg/toolkit/dynamic_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func (dpc *DynamicParameterContext) GetValue() (any, error) {
}

func (dpc *DynamicParameterContext) GetRawValue() (any, error) {
return dpc.rc.GetColumnRawValue(dpc.column.Name)
return dpc.rc.GetRawColumnValue(dpc.column.Name)
}

func (dpc *DynamicParameterContext) GetColumnValue(name string) (any, error) {
return dpc.rc.GetColumnValue(name)
}

func (dpc *DynamicParameterContext) GetColumnRawValue(name string) (any, error) {
return dpc.rc.GetColumnRawValue(name)
func (dpc *DynamicParameterContext) GetRawColumnValue(name string) (any, error) {
return dpc.rc.GetRawColumnValue(name)
}

func (dpc *DynamicParameterContext) EncodeValue(v any) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/toolkit/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func newRecordContext(driver *Driver) (*RecordContext, []expr.Option) {
fmt.Sprintf("__raw__%s", c.Name),
func(name string) func(params ...any) (any, error) {
return func(params ...any) (any, error) {
return rctx.GetColumnRawValue(name)
return rctx.GetRawColumnValue(name)
}
}(c.Name),
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/toolkit/template_record_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (rc *RecordContext) GetColumnValue(name string) (any, error) {
return v.Value, nil
}

func (rc *RecordContext) GetColumnRawValue(name string) (any, error) {
func (rc *RecordContext) GetRawColumnValue(name string) (any, error) {
v, err := rc.record.GetRawColumnValueByName(name)
if err != nil {
return nil, err
Expand All @@ -87,7 +87,7 @@ func (rc *RecordContext) SetColumnValue(name string, v any) (bool, error) {
return true, nil
}

func (rc *RecordContext) SetColumnRawValue(name string, v any) (bool, error) {
func (rc *RecordContext) SetRawColumnValue(name string, v any) (bool, error) {
var val *RawValue
switch vv := v.(type) {
case NullType:
Expand Down