Skip to content

Commit

Permalink
fix: Rename MergeOptions to Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rlch committed Aug 22, 2023
1 parent cfc7899 commit 4140139
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions db/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func RemoveLabels(identifier client.PropertyIdentifier, labels ...string) intern
// [MERGE]: https://neo4j.com/docs/cypher-manual/current/clauses/merge/
func OnCreate(set ...internal.SetItem) internal.MergeOption {
return &internal.Configurer{
MergeOptions: func(mo *internal.MergeOptions) {
Merge: func(mo *internal.Merge) {
mo.OnCreate = append(mo.OnCreate, set...)
},
}
Expand All @@ -89,7 +89,7 @@ func OnCreate(set ...internal.SetItem) internal.MergeOption {
// [MERGE]: https://neo4j.com/docs/cypher-manual/current/clauses/merge/
func OnMatch(set ...internal.SetItem) internal.MergeOption {
return &internal.Configurer{
MergeOptions: func(mo *internal.MergeOptions) {
Merge: func(mo *internal.Merge) {
mo.OnMatch = append(mo.OnMatch, set...)
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ func (cy *cypher) writeMergeClause(
node *nodePattern,
opts ...MergeOption,
) {
merge := &MergeOptions{}
merge := &Merge{}
for _, opt := range opts {
opt.configureMergeOptions(merge)
opt.configureMerge(merge)
}
cy.catch(func() {
cy.WriteString("MERGE ")
Expand Down
14 changes: 7 additions & 7 deletions internal/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package internal

import "github.com/goccy/go-json"

func ConfigureMergeOptions(o *MergeOptions, configurer MergeOption) {
configurer.configureMergeOptions(o)
func ConfigureMerge(o *Merge, configurer MergeOption) {
configurer.configureMerge(o)
}

func ConfigureVariable(v *Variable, configurer VariableOption) {
Expand All @@ -19,7 +19,7 @@ func ConfigureWhere(w *Where, configurer WhereOption) {
}

type Configurer struct {
MergeOptions func(*MergeOptions)
Merge func(*Merge)
Variable func(*Variable)
ProjectionBody func(*ProjectionBody)
Where func(*Where)
Expand All @@ -32,8 +32,8 @@ var _ interface {
WhereOption
} = (*Configurer)(nil)

func (c *Configurer) configureMergeOptions(o *MergeOptions) {
c.MergeOptions(o)
func (c *Configurer) configureMerge(o *Merge) {
c.Merge(o)
}

func (c *Configurer) configureVariable(v *Variable) {
Expand All @@ -50,9 +50,9 @@ func (c *Configurer) configureWhere(w *Where) {

type (
MergeOption interface {
configureMergeOptions(*MergeOptions)
configureMerge(*Merge)
}
MergeOptions struct {
Merge struct {
OnCreate []SetItem
OnMatch []SetItem
}
Expand Down

0 comments on commit 4140139

Please sign in to comment.