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

Break the loop when the sql operator has been found. #105

Open
mapogolions opened this issue Mar 31, 2021 · 2 comments
Open

Break the loop when the sql operator has been found. #105

mapogolions opened this issue Mar 31, 2021 · 2 comments

Comments

@mapogolions
Copy link

mapogolions commented Mar 31, 2021

At the moment, when operator has been found the loop continues its work. Please, take a look at the following piece of code

value = value.substring(len);

As a result, if you pass the below input to the function, the last operator (<=) will be resolved.

const { clause } = where({ age: '>=<=18' });
console.log(clause); // 'age <='

Maybe in this case it makes sense to use the break statement.

@tshemsedinov
Copy link
Member

@mapogolions Can't understand, maybe you can explain in Russian here: https://github.com/metarhia/metasql/discussions

@OleksiiKachan
Copy link
Member

OleksiiKachan commented Jun 23, 2021

@tshemsedinov from what I understand

for (const op of OPERATORS) {

this loop keeps running even after value is found. in his example, if you pass >=, it finds it on the first iteration, but the loop does not stop. it keeps going till it iterates over all OPERATORS.
I think breaking the loop makes sense. if not, can you explain why?

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

3 participants