Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Check field in ConditionConfig doesn't allow comparison against parameters #11

Open
JimFicarra opened this issue Feb 6, 2022 · 0 comments

Comments

@JimFicarra
Copy link

Problem Summary

When using incoming arguments/parameters for a cypher query, this library doesn't seem to have a way to compare against arguments.

Detail

You set a parameter ahead of the query as follows for Neo:

:param ARGS => ({memberOf:"0215a21f-2504-4769-b878-b9af2cf49d50" })

This is the query hand-written to use this argument

WITH $ARGS AS args MATCH (u:USER)-[MEMBER_OF]->(o) WHERE o.uuid = args.memberOf RETURN u

The cypher-dsl to create this as closely as possible is as follows - however the comparison to the parameter has single quotes around it:

cypher, err := dsl.QB().
		With(&dsl.WithConfig{
			Parts: []dsl.WithPart{{
				Name: "$ARGS",
				As:   "args",
			}},
		}).
		Match(dsl.Path().V(dsl.V{Name: "u", Type: "USER"}).
			E(dsl.E{
				Direction: dsl.DirectionOutgoing,
				Name:      "MEMBER_OF",
			}).V(dsl.V{Name: "o"}).Build()).
		Where(dsl.C(&dsl.ConditionConfig{
			ConditionOperator: dsl.EqualToOperator,
			Name:              "o",
			Field:             "uuid",
			Check:             "args.memberOf",
		})).
		Return(false, dsl.ReturnPart{Name: "u"}).
		ToCypher()

produces

WITH $ARGS AS args MATCH (u:USER)-[MEMBER_OF]->(o) WHERE o.uuid = 'args.memberOf' RETURN u

...which ends up comparing o.uuid to the string value 'args.memberOf' instead.

For kicks & giggles I tried to change Check to the following to see if it would be handled more cleanly.

Check:             []byte("args.memberOf"),

But then I got:

errors found: (1) errors occurred: kind check failed, this should not have happened -- total errors (1)

Questions

  • Is there a way to compare against arguments?
  • Is there a more extensive set of documentation and examples? The library has no examples to follow. I had to dig through the library code and the tests to get an idea of how to use it. The docs at https://pkg.go.dev/github.com/mindstand/[email protected] are somewhat minimal.

Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant