Skip to content

String variables misinterpreted as floats when floats exist in context #16

Description

@dpro-djapa

When evaluating rules that compare a string variable to a string literal, the library misinterprets the string literal as a float if there are float values present in the evaluation context.

record = {'var':'epa1',"var_2":10,"var_3":0.4}
ctx = Context(record)
result = evaluate('var == "epa1"', ctx) # The literal 'epa1' is actually being interpreted as epa1.0`
print(result) #<-This is False
result2 =  evaluate('string("epa1")', ctx)
print(result2) #<-This is epa1.0

Edit: The number doesn't have to be at the end of the string for it to be converted to float. "epa1epa" -> epa1.0epa

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions