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

Containability, GTEQ, and LTEQ filter problem in couchbase #218

Open
jgomer2001 opened this issue Jan 8, 2021 · 1 comment
Open

Containability, GTEQ, and LTEQ filter problem in couchbase #218

jgomer2001 opened this issue Jan 8, 2021 · 1 comment
Assignees

Comments

@jgomer2001
Copy link
Contributor

Say I have data like

user1 = {
  "attribute": "test"
  ...
}
user2= {
  "attribute": ["test1", "test2"],
  ...
}

I have no control on how attribute is stored. Some entries have it as single string, sometimes as array of strings

Suppose I want to run a query of users where attribute contains the word test. I do:

Filter.createSubstringFilter("attribute", null, new String[]{ "test" }, null).multiValued(null);

which generates

2021-01-08 16:19:28,291 DEBUG [qtp990355670-13] [gluu.persist.couchbase.operation.impl.CouchbaseOperationServiceImpl] (CouchbaseOperationServiceImpl.java:555) - Execution query: 
'SELECT gluu_doc.*, dn FROM `gluu_user` AS gluu_doc
WHERE ( ( objectClass = "gluuPerson" ) AND mail LIKE "%test%" )'

That will retrieve user1 only, not user2. The same expression is obtained when using .multiValued(false) which in that case would be correct.

Using .multiValued(true) does the right thing too:

2021-01-08 16:32:52,004 DEBUG [qtp990355670-15] [gluu.persist.couchbase.operation.impl.CouchbaseOperationServiceImpl] (CouchbaseOperationServiceImpl.java:555) - Execution query: 
'SELECT gluu_doc.*, dn FROM `gluu_user` AS gluu_doc 
WHERE ( ( objectClass = "gluuPerson" ) AND ANY mail_ IN mail SATISFIES mail_ LIKE "%test%" END ) ...

So basically we need an OR in order to glue the two expressions when multivalued = null. The equality filter is already working that way.

I will take a look on other usages (endsWith, etc..)

@jgomer2001
Copy link
Contributor Author

The same problem occurs with createGreaterOrEqualFilter and createLessOrEqualFilter where the following is generated when multiValued is null or not set:

WHERE (  numeric >= 0 )

WHERE (  numeric <= 0 )

@jgomer2001 jgomer2001 changed the title Containability filter problem in couchbase Containability, GTEQ, and LTEQ filter problem in couchbase Jan 10, 2021
@yurem yurem transferred this issue from GluuFederation/oxCore May 20, 2021
@jgomer2001 jgomer2001 transferred this issue from GluuFederation/oxTrust Jun 8, 2021
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