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

Allow sets to be dereferenced #243

Closed
tsandall opened this issue Feb 2, 2017 · 0 comments · Fixed by #251
Closed

Allow sets to be dereferenced #243

tsandall opened this issue Feb 2, 2017 · 0 comments · Fixed by #251

Comments

@tsandall
Copy link
Member

tsandall commented Feb 2, 2017

Today, queries cannot dereference sets (doing so results in a runtime error). It would be nice if this wasn't the case.

Instead of:

p[x], x.foo = "bar"

We could write:

p[_].foo = "bar"

To deal with this, we will bind set references to their value. We can explain this as s[x].foo = bar is syntactic sugar for s[x], x.foo = bar.

With respect to implementation, we must handle the following case:

p = {false}
p[x], ... # evaluation should not stop even though p[x] will be bound to false.
tsandall added a commit to tsandall/opa that referenced this issue Feb 7, 2017
In the past, topdown would bind set[x] to true. This resulted in
confusion when people attempted to write joins with set elements.

With this change, topdown treats sets like objects/arrays, except that
set[x] is bound to x. This allows users to write queries that
dereference sets just like objects and arrays.

Also, fix handling of self-joins where previously a recursive binding
could be added. The "self-join" test case was added to cover this.

Fixes open-policy-agent#243
tsandall added a commit that referenced this issue Feb 7, 2017
In the past, topdown would bind set[x] to true. This resulted in
confusion when people attempted to write joins with set elements.

With this change, topdown treats sets like objects/arrays, except that
set[x] is bound to x. This allows users to write queries that
dereference sets just like objects and arrays.

Also, fix handling of self-joins where previously a recursive binding
could be added. The "self-join" test case was added to cover this.

Fixes #243
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

Successfully merging a pull request may close this issue.

1 participant