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

Is it possible to use arguments as selectors? #40

Open
AnbazhakanSubramaniam opened this issue Sep 16, 2019 · 1 comment
Open

Is it possible to use arguments as selectors? #40

AnbazhakanSubramaniam opened this issue Sep 16, 2019 · 1 comment

Comments

@AnbazhakanSubramaniam
Copy link

Hi, I'm trying to check if the values of two attributes in the database are identical.
Currently the "arguments" field supports only the values of the entries.

So, Is it possible to use/extend the "arguments" as "selectors"?

For ex: The database entry has the following

	Name : "Item1"
		Attributes:
		ParameterA : "ParamA1"
		ParameterB : "ParamB1"
		
	Name : "Item2"
		Attributes:
			ParameterA : "ParamA2"
			ParameterB : "ParamA2"

Here, the query Attributes.ParameterA=="ParamA1" works fine and fetches the "Item1" as a result.

Now, I would like to query the list of "Items" whose Parameters are identical.

Query will be, Attributes.ParameterA==Attributes.ParameterB should fetch "Item2"

Kindly let me know if its feasible.

Thanks

@davebaol
Copy link

Maybe a bit tricky but thanks to custom operators you can do what you need.
Imagine the generic regular custom operator =xyz= expecting a constant argument (possibly casted).
Then imagine its mirror version =xyzat= (where suffix 'at' means 'at path') expecting - guess what - a path (not casted, it's just a regular string as for any other selector).
I got it working by taking inspiration from all the code at #29.
I suggest you to read all the thread and take the best from each sample code.
Then to parse the selector argument you can reuse a slightly modified version of the parseProperty method that takes the path in input, instead of using the instance variable property.
Hope that helps.

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

No branches or pull requests

2 participants