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

tsl_mem with like keyword #7

Closed
rawsyntax opened this issue May 30, 2019 · 2 comments · Fixed by #9
Closed

tsl_mem with like keyword #7

rawsyntax opened this issue May 30, 2019 · 2 comments · Fixed by #9
Labels
enhancement New feature or request question Further information is requested

Comments

@rawsyntax
Copy link
Contributor

Should the tsl_mem binary work with like? For example:

./tsl_mem -i "author like '%joe%'"
2019/05/30 12:37:51 unexpected literal: $like

I see it listed as part of the grammar and used with other tsl binaries

@yaacov yaacov added the question Further information is requested label May 30, 2019
@yaacov
Copy link
Owner

yaacov commented May 30, 2019

Hi, thanks for the issue ❤️

TSL language definition and implementations:

So TSL has two sets of string operators for "like":

1 - The SQL like:
https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L33
https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L34

2 - The NoSQL regexp:
RegexOp: https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L31

I did not implement all the operator in all the walkers ... , for example the SQL implementation did not implement the regexp operator, while the mongo one will skip the like.

tsl_mem

./tsl-mem example use the semantic walker to implement an in memory database:
https://github.com/yaacov/tree-search-language/blob/master/cmd/tsl_mem/main.go#L31

Semantic Walker

When giving semantic meaning to the operators in semantic pkg ( https://godoc.org/github.com/yaacov/tree-search-language/pkg/walkers/semantics ) I only implemented the Regexp operator:

In the function that handle string operators:
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L192
I only implemented:
RegExp:
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L212

And like falls into unexpected literal here:
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L226


P.S.

This will also happen in the mongo walker:
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/mongo/walk.go#L79
That only implement Regexp:
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/mongo/walk.go#L110

But not in the SQL walker 😄 :
https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/sql/walk.go#L139

@yaacov yaacov added the enhancement New feature or request label Jun 1, 2019
@yaacov yaacov closed this as completed in #9 Jun 1, 2019
@rawsyntax
Copy link
Contributor Author

@yaacov thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants