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

String Array #9

Closed
alihangokdemir opened this issue Jan 20, 2021 · 5 comments
Closed

String Array #9

alihangokdemir opened this issue Jan 20, 2021 · 5 comments

Comments

@alihangokdemir
Copy link

Hello, Is it possible to match string array?

rawYQL = stringArray in ('test1')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"stringArray": []string{"test1","test2"},
})

@caibirdme
Copy link
Owner

If you mean intersection operation, yes.

rawYQL := "strArr ∩ ('test1')"

pay attention to the operator , it's the same as that in math, not alphabet n

@alihangokdemir
Copy link
Author

Thank you for the answer.

When I run this code below, I got true as a result.
rawYQL := letter ∩ ('a','b')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a"},
})

What if the rawYQL = letter ∩ ('a') and my letter array be []string{"a","b","c"}. How can I check this?

I tried,
rawYQL := letter ∩ ('a')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a","b","c"},
})

and

rawYQL := letter in ('a')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a","b","c"},
})

but I got false as a result.

@caibirdme
Copy link
Owner

Thank you for the answer.

When I run this code below, I got true as a result.
rawYQL := letter ∩ ('a','b')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a"},
})

What if the rawYQL = letter ∩ ('a') and my letter array be []string{"a","b","c"}. How can I check this?

I tried,
rawYQL := letter ∩ ('a')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a","b","c"},
})

and

rawYQL := letter in ('a')
result, _ = yql.Match(rawYQL, map[string]interface{}{
"letter": []string{"a","b","c"},
})

but I got false as a result.

Sorry, I confirmed this is a bug. When there's only one element in set, yql find you're going to compare an array and an string, so, false. But if the operator is ∩, it should convert the element to an array, and then do the comparison. I'll fix it soon.

@alihangokdemir
Copy link
Author

Thank you. I will be waiting.

@caibirdme
Copy link
Owner

Thank you. I will be waiting.

@alihangokdemir Fixed, Use letter ∩ ('a','b')

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

2 participants