Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

fixed uniqueWithin validation bugs. #74

Merged
merged 3 commits into from
Oct 27, 2015
Merged

Conversation

mandric
Copy link
Contributor

@mandric mandric commented Oct 27, 2015

Issue: https://github.com/medic/medic-projects/issues/56

This validation was failing because the lucene query was incorrectly
constructed.

  • To query on integer values we need to use the prefix on the
    query otherwise the query doesn't match and always returns an empty
    array.

  • formatParam was failing on integer values with:

    lib/validation.js:36
    value = value.replace(/"/g, '"');
    ^
    TypeError: Object 1 has no method 'replace'

  • It seems the ISO date standard (the one returned by .toISOString()
    with the trailing Z that designates Zulu/GMT time) fails on Lucene. I
    opened an upstream issue for this and left a comment in the code.

Net change looks like this:

// fails

patient_name:"irene" AND last_menstrual_period:"1" AND reported_date:[2015-07-27T13:14:40.564Z TO 3000-01-01T00:00:00]

// works

patient_name:"irene" AND last_menstrual_period<int>:1 AND reported_date:[2015-07-27T13:14:40.564 TO 3000-01-01T00:00:00]

Milan Andric added 3 commits October 27, 2015 11:27
Issue: https://github.com/medic/medic-projects/issues/56

This validation was failing because the lucene query was incorrectly
constructed.

- To query on integer values we need to use the <int> prefix on the
  query otherwise the query doesn't match and always returns an empty
  array.

- formatParam was failing on integer values with:

    lib/validation.js:36
    value = value.replace(/"/g, '\\"');
                  ^
    TypeError: Object 1 has no method 'replace'

- It seems the ISO date standard (the one returned by .toISOString()
  with the trailing Z that designates Zulu/GMT time) fails on Lucene.  I
  opened an upstream issue for this and left a comment in the code.

Net change looks like this:

// fails
```
patient_name:"irene" AND last_menstrual_period:"1" AND reported_date:[2015-07-27T13:14:40.564Z TO 3000-01-01T00:00:00]
```

// works
```
patient_name:"irene" AND last_menstrual_period<int>:1 AND reported_date:[2015-07-27T13:14:40.564 TO 3000-01-01T00:00:00]
```
@mandric
Copy link
Contributor Author

mandric commented Oct 27, 2015

Feel free to merge when it's ready browndav.

@mandric
Copy link
Contributor Author

mandric commented Oct 27, 2015

browndav I was hoping to get this in RC today so let me know if there's anything I can do to help.

@ghost
Copy link

ghost commented Oct 27, 2015 via email

mandric added a commit that referenced this pull request Oct 27, 2015
@mandric mandric merged commit 6bd49fa into master Oct 27, 2015
@mandric mandric deleted the uniquewithin-validation-fix branch October 27, 2015 14:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant