Giter VIP home page Giter VIP logo

jexl-rs's Introduction

jexl-rs's People

Contributors

atouchet avatar dmose avatar eoger avatar jeddai avatar jhugman avatar johnsonw avatar mythmon avatar tarikeshaq avatar vladikoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jexl-rs's Issues

minus number error

I found an error "UnrecognizedToken { token: (8, Token(14, "-"), 9)"
ex. : let rs = eval.eval("{a: -3}")?;

and no error if: let rs = eval.eval("{a: 0-3}")?;

please fix this.

Figure out what to do with `undefined` attributes

Currently, attributes not defined in the context are interpreted as null.

Prior to version 0.2.0, null was not supported in any binary operations.

This meant that expressions with missing attribute errored: not because the attribute was missing, but because binary operations on null were not supported.

Missing attributes can come from:

  1. the expression authors mistyping an identifier.
  2. attributes in one version of the context, but not in another.

We'd like expression authors to be able detect the absence of an attribute in their expressions:

e.g.

attr_v2 ? attr_v2 == 'value' : attr == 'value'
attr_v2 && attr_v2 == 'value'

This issue is to make undefined attributes error, BUT make is_truthy for undefined return false.

Sanity pass over tests

We need to make sure our implementation isn't missing anything large,

I have a feeling we'll need to do some reordering of the expressions in the .lalrpop file once we test against a complex example

Support for more `boolean` binary expressions

Similar to #15, binary expressions with boolean values are not available. AND and OR are supported, but

==
!=
XOR

…and others are missing.

Without a boolean comparison (==) or NOT (!) this makes boolean context values much less useful.

Clean up error handling

There are a few unwraps in the code base that should be errors instead

Additionally the lifetime stuation with the errors is a little annoying

Probably will have two prs here, a mandatory replacement of the unwraps and an overall cleanup.

Fix failing tests

There are a bunch of failing test with #[should_panic]

We should fix those

Can't perform binary operations on null

Trying to evaluate var == null when var is not defined in the context leads to the following error result value:

Invalid binary operation, left: null, right: null, operation: Equal

Add documentation

A couple of pieces here

  • Add rust docs to the eval functions of the Evaluator
  • Add comments/docs to the .lalrpop file, for future maintainablility

An expression may evaluate to `Null` but an equality test evaluates to `UndefinedIdentifier`

Consider the following:

let evaluator = Evaluator::new();

let context = value!({
    "foo": null,
});

let expr = "foo".to_string();

let r = evaluator.eval_in_context(&expr, context).unwrap();

In the above snippet, foo will evaluate to null. This is the same behavior that is seen in jexl. If we expand this to an equality test, however, you will see that the binary comparison is not currently possible:

...
let expr = "foo == null".to_string();
let r = evaluator.eval_in_context(&expr, context).unwrap();

This will produce the following error:

thread '...' panicked at 'called `Result::unwrap()` on an `Err` value: UndefinedIdentifier("null")', jexl-eval/src/lib.rs:816:59

Equality comparisons should allow for null identifiers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.