Skip to content

Commit

Permalink
fix: minor correction on value convertion for comparation in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Jan 10, 2024
1 parent 81d9a88 commit efe5595
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.metadata.schema.OType;
import java.util.Map;

Expand Down Expand Up @@ -50,7 +51,13 @@ public boolean execute(Object iLeft, Object iRight) {
iLeft = couple[0];
iRight = couple[1];
} else {
iRight = OType.convert(iRight, iLeft.getClass());
try {
iRight = OType.convert(iRight, iLeft.getClass());
} catch (RuntimeException e) {
// Can't convert to the target value.
OLogManager.instance()
.warn(this, "Issue converting value to target type, ignoring value", e);
}
}
if (iRight == null) return false;
return ((Comparable<Object>) iLeft).compareTo(iRight) >= 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.metadata.schema.OType;
import java.util.Map;
Expand All @@ -27,7 +28,13 @@ public boolean execute(Object iLeft, Object iRight) {
iLeft = couple[0];
iRight = couple[1];
} else {
iRight = OType.convert(iRight, iLeft.getClass());
try {
iRight = OType.convert(iRight, iLeft.getClass());
} catch (RuntimeException e) {
// Can't convert to the target value do nothing will return false
OLogManager.instance()
.warn(this, "Issue converting value to target type, ignoring value", e);
}
}
if (iRight == null) return false;
if (iLeft instanceof OIdentifiable && !(iRight instanceof OIdentifiable)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.metadata.schema.OType;
import java.util.Map;

Expand Down Expand Up @@ -29,7 +30,13 @@ public boolean execute(Object iLeft, Object iRight) {
iLeft = couple[0];
iRight = couple[1];
} else {
iRight = OType.convert(iRight, iLeft.getClass());
try {
iRight = OType.convert(iRight, iLeft.getClass());
} catch (RuntimeException e) {
// Can't convert to the target value do nothing will return false
OLogManager.instance()
.warn(this, "Issue converting value to target type, ignoring value", e);
}
}
if (iRight == null) return false;
return ((Comparable<Object>) iLeft).compareTo(iRight) <= 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.metadata.schema.OType;
import java.util.Map;

Expand All @@ -26,7 +27,13 @@ public boolean execute(Object iLeft, Object iRight) {
iLeft = couple[0];
iRight = couple[1];
} else {
iRight = OType.convert(iRight, iLeft.getClass());
try {
iRight = OType.convert(iRight, iLeft.getClass());
} catch (RuntimeException e) {
// Can't convert to the target value do nothing will return false
OLogManager.instance()
.warn(this, "Issue converting value to target type, ignoring value", e);
}
}
if (iRight == null) return false;
return ((Comparable<Object>) iLeft).compareTo(iRight) < 0;
Expand Down

0 comments on commit efe5595

Please sign in to comment.