biocodellc / biocode-fims-commons

Biocode Field Information Management System
3 stars 0 forks source link

validateNumeric not processing #4

Closed jdeck88 closed 8 years ago

jdeck88 commented 8 years ago

This comes from the SI configuration and used to work but now gives the following error:

Value out of range 38.89707 for "Latitude Decimal" using range validation = %3E%3D-90+and+%3C%3D90

that should be a valid value... This looks like it may just be an encoding issue for the rule ...

rodney757 commented 8 years ago

Hmm, are you sure that this used to work?

The query is:

"SELECT Latitude_Decimal FROM Samples WHERE abs(Latitude_Decimal) >=-90 and abs(Latitude_Decimal) <=90 and Latitude_Decimal != "";"

Then we are throwing an error when a value is returned.

The issues are

  1. After looking at other rules in the xml configs, it appears that we should actually be negating the where clauses. The rule values are for the range the number should fall between. Our query above selects for that, but then throws an error when a value is present.
  2. Also, I found and fixed a bug where SqlExceptions were being returned when querying for a column that contained "(" (ex. "DepthFrom(m)"). The exception was saying that column "m" could not be found, therefore the rule was being bypassed, potentially allowing invalid values to be entered.

The above should be fixed with commit a8491ab2348de837b7431620a399f927347a7881. The column names are now enclosed with ``. The validateNumeric query now selects for values that are not a number, or fall outside of the provided range.

jdeck88 commented 8 years ago

yes it should have previously worked... this was a test file used previously.

I updated changes and see that it now decodes the expression on the display, which is nice.

However, i just discovered that the errors are related to cases where there are no values in the lat/lng (and other numeric) fields.... Try loading data with no values for latitude/longitude... just realized the ones without any data throw the error. I forget exactly how the numeric processing worked in the code/sql (and just about to board plan so can't dig into it now) but i think it was the sql itself which checked and accounted for null/empty values in fields during numeric validation.

John

rodney757 commented 8 years ago

Ya, I forgot to include a set of parentheses in the query. Commit acada81 should be the fix.

I'm still confused how the previous query could have worked. Anyways, I think its correct now.