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

'.val()' not added when prior() inside square brackets. #252

Open
siddhantkothari opened this issue Aug 24, 2020 · 1 comment
Open

'.val()' not added when prior() inside square brackets. #252

siddhantkothari opened this issue Aug 24, 2020 · 1 comment

Comments

@siddhantkothari
Copy link

A simple reproducible example showing the bug:

.bolt file:
path /test/{x} is String{ validate() { this.parent()[prior(this)] == x } }
.json file produced:
{ "rules": { "test": { "$x": { ".validate": "(newData.isString() && newData.parent().child(data).val() == $x)" } } } }
.json file expected:
{ "rules": { "test": { "$x": { ".validate": "(newData.isString() && newData.parent().child(data.val()).val() == $x)" } } } }
Inside the child function data.val() should be present.
When I remove the prior(), the result is newData.val() as expected.

@Nickk4
Copy link

Nickk4 commented Jan 11, 2024

To add a similar issue where .val() is not added:

path /{project_uuid} {
  read() {
    projectMatch(this.parent_uuid)
  }
}

function projectMatch(parent_uuid) {
  return (
    auth != null &&
    parent_uuid != null &&
    auth[parent_uuid] != null
  );
}

The last line compiles into:

auth[data.child('parent_uuid')] != null

instead of

auth[data.child('parent_uuid').val()] != null

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