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

Expressions with Spaces #14

Open
jfinch1991 opened this issue Feb 27, 2017 · 8 comments
Open

Expressions with Spaces #14

jfinch1991 opened this issue Feb 27, 2017 · 8 comments

Comments

@jfinch1991
Copy link

Im trying to get this to parse expressions with spaces e.g. Net Income > 10000. I have tried a few things like wrapping with quotes "Net Income" but that hasn't worked. Any ideas?

@msantos
Copy link
Contributor

msantos commented Feb 27, 2017

Use single quotes:

var e = "'a b' > 3"                                                             
var f = compileExpression(e)                                                    
f({"a b": 1}) // 0                                                              
f({"a b": 4}) // 1

@summer9090
Copy link

met the same issue, tried using quotes, but it doesn't work, showing: Unrecognized text error

Any advice?

@msantos
Copy link
Contributor

msantos commented Jun 9, 2017

If you want help, show the code that isn't working.

To debug this yourself, open a page that loads filtrex. Then open the javascript console and enter in the code from #14 (comment). Change the expression to match your input and re-test.

@summer9090
Copy link

I am using the same example you replied @jfinch1991 , the code is as follows:

function hello() {
var e = "'a b' > 3"
var myfilter = compileExpression(e);
myfilter({"a b": 2});
}

Uncaught Error: Lexical error on line 1. Unrecognized text.
'a b' > 3
^

Thanks for advice

@msantos
Copy link
Contributor

msantos commented Jun 14, 2017

Works for me. Try running the tests, in particular check the test for "quoted symbols" passes. To be sure, you can add a test case with whitespace:

diff --git a/test/filtrex-test.html b/test/filtrex-test.html
index d0ba6ed..49a5afe 100644
--- a/test/filtrex-test.html
+++ b/test/filtrex-test.html
@@ -128,6 +128,7 @@ tests({

     'quoted symbols': function() {
         eq(123, compileExpression('\'hello-world-foo\'')({'hello-world-foo': 123}));
+        eq(123, compileExpression('\'hello world foo\'')({'hello world foo': 123}));
         eq(123, compileExpression('\'order+goo*and#stuff\'')({'order+goo*and#stuff': 123}));
     },

If the tests work, verify your version of filtrex.js is up to date.

@summer9090
Copy link

Thanks for your reply.

I cloned this project and run the tests, all passed. But in my project, I installed filtrex(version: 0.5.4) through npm. When I run the same test('quoted symbol'), it will pop up the errors above. Is the filtrex version in node repository the latest one?

Thanks.

@summer9090
Copy link

Any updates about the issue?

Thanks

@cshaa
Copy link
Contributor

cshaa commented Mar 1, 2020

The issue was caused by NPM not being up-to-date. As of 2019 this is no longer the case and the NPM package is being actively maintained again.

@github-staff github-staff deleted a comment from mehdi-dev97 May 27, 2024
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

4 participants