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

with keyword doesn't yield correct result when applied to rules #1261

Closed
tsandall opened this issue Mar 13, 2019 · 0 comments
Closed

with keyword doesn't yield correct result when applied to rules #1261

tsandall opened this issue Mar 13, 2019 · 0 comments
Labels

Comments

@tsandall
Copy link
Member

Expected Behavior

The with keyword should be able to mock virtual documents.

Actual Behavior

Queries that iterate over virtual documents are seeing the underlying values generated by rules instead of the mocked value.

Example:

package play

## Reference (working)
q1 = {"a": 1}
p1 = x { q1.a = x }
r1 = q1
test1 {
   p1 = x with q1 as {"a": 2} # working
   r1 = y with q1 as {"a": 2} # working
}


## Iteration (broken)
q[1]
q[2]
q[3]

p[x] { q[x] }
r = q

test {
	p = x with q as {4,5,6}  # broken
    r = y with q as {4,5,6}  # working
}

Tested on

@tsandall tsandall added the bug label Mar 13, 2019
tsandall added a commit to tsandall/opa that referenced this issue Apr 15, 2019
Previously the implementation was using the ref term that may be
non-ground (which would result in a cache miss.) Also, rename second
return value name to more clearly communicate intent.

Also, fix eval-tree enumeration to support sets that may be returned
by resolver when with keyword has been applied.

Fixes open-policy-agent#1261

Signed-off-by: Torin Sandall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

1 participant