Skip to content

Why are only two values returned why in the wrong order? #92

Discussion options

You must be logged in to vote

That's just the characteristics of the set data type (unordered, unique items). This often maps well to the policy domain, where you have things like roles and permissions, and duplicates rarely make sense (e.g. what's the meaning of having two roles named admin?) and order is normally not important.

If that's not what you want, you would instead use arrays. Rego doesn't have "array generating rules" like the rule generating a set in your example, but you could use an array comprehension to create an array out of items from the input:

rr_array := [y | x := input.rr_sets[_]
                 y := {"name": x.name}]

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@firstdorsal
Comment options

Answer selected by firstdorsal
Comment options

You must be logged in to vote
1 reply
@firstdorsal
Comment options

Comment options

You must be logged in to vote
2 replies
@anderseknert
Comment options

@firstdorsal
Comment options

Comment options

You must be logged in to vote
1 reply
@anderseknert
Comment options

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