-
Notifications
You must be signed in to change notification settings - Fork 4
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
Filter Implementation #28
Conversation
|
||
public Condition visitIntValue(Value v, org.jooq.Field left, String conditionName) { | ||
Condition c = null; | ||
if(conditionName.equals("eq")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job! I see you have all arguments covered. Is that ready for verification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to implement in
and between
for float
and int
types.
" ) \"accounts\"\n" + | ||
"from PUBLIC.CUSTOMER \"g0\"\n" + | ||
"where (\n" + | ||
" (\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result of this is not correct. it should be like lastname = 'smith' and firstname='John' and ssn = 'cst01002'
a or
as enclosing does not mean the attributes inside are separated by or
. or
is always adjunct operation where you could have said
{
customers (filter: {
LASTNAME: {
eq: "Smith"
},
FIRSTNAME: {
eq: "John"
},
or: {
SSN: {
eq: "CST01002"
}
}
}
}
which should result in (lastname = 'smith' and firstname='John' ) or ssn = 'cst01002'
overall what I am saying or
should not have had any effect on the query above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out that, I will correct it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We found ourselves looking at the semantics of or
operator recently in Graphback
/cc @craicoverflow if you want to share your experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, We checked out competitors (AppSync) and their query output match that by @rareddy above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ani-sha did you make sure the previous original test as is should have behaved the way I listed above, as the test is not wrong the results were
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ani-sha keep the test case as is from before, make sure the results were correct.
"from PUBLIC.CUSTOMER \"g0\"\n" + | ||
"where (\n" + | ||
" \"g0\".\"LASTNAME\" like ('%' || replace(\n" + | ||
" replace(\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is JOOQ doing this conversion? seems cryptic, most databases have startsWith
and contains
kind of functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it's JOOQ. I didn't understand it as well.
@@ -200,7 +188,7 @@ public void startVisitRootObject(Field rootField, GraphQLFieldDefinition rootDef | |||
} | |||
|
|||
@Override | |||
public void endVisitRootObject(Field rootFeild, GraphQLFieldDefinition rootDefinition, GraphQLObjectType type) { | |||
public void endVisitRootObject(Field rootField, GraphQLFieldDefinition rootDefinition, GraphQLObjectType type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to learn how to spell field
, I make this mistake quite often :)
@@ -271,67 +273,130 @@ public void visitArgument(Field field, GraphQLFieldDefinition definition, GraphQ | |||
|
|||
public Condition visitStringValue(Value v, org.jooq.Field left, String conditionName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the parameter Value v' to
String` and remove the class castings below. When you are calling this method you already know the type just cast once there. Same for others below too
Condition c = null; | ||
switch (conditionName) { | ||
case "between": | ||
if (v.get(0) instanceof FloatValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even they are single line if
or for
routines wrap them with curly {
braces, makes it easier to read the code
for (Value value : v) | ||
list.add(((IntValue) value).getValue()); | ||
c = left.in(list); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put in a default
in here and throw a runtimeexception
saying wrong condition
break; | ||
case "ge": | ||
c = left.ge(((FloatValue) v).getValue()); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put in default
here and throw a RuntimeException
saying wrong condition same at all other similar places.
visitCondition(finalConditionName, condition); | ||
}); | ||
for(Object object : field.getValue().getChildren()) { | ||
if(object instanceof ObjectField) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can there be any other value than ObjectField
here? if yes capture that in else, you can throw an exception that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from ObjectField
, we don't need to create Condition
for others we just simply continue.
c815665
to
baf521e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Initial Version - Addition of filtering capabilities #16, few cases are yet to be validated.