Skip to content
Snippets Groups Projects
Commit c882cb42 authored by Paolo Guagliardo's avatar Paolo Guagliardo
Browse files

Fix evaluation of conditions with constants (WIP)

parent c8f96f0f
Branches feature/sqlite
No related tags found
No related merge requests found
......@@ -54,9 +54,9 @@ public class Equality extends Condition {
@Override
public String toSQL() {
String left = this.left.isAttribute() ?
Database.encode(this.left.getValue()) : "'" + this.left.getValue() + "'";
Database.encode(this.left.getValue()) : this.left.getValue();
String right = this.right.isAttribute() ?
Database.encode(this.right.getValue()) : "'" + this.right.getValue() + "'";
Database.encode(this.right.getValue()) : this.right.getValue();
return left + " = " + right;
}
}
......@@ -55,10 +55,19 @@ public class LessThan extends Condition {
@Override
public String toSQL() {
String left = this.left.isAttribute() ?
Database.encode(this.left.getValue()) : "'" + this.left.getValue() + "'";
String right = this.right.isAttribute() ?
Database.encode(this.right.getValue()) : "'" + this.right.getValue() + "'";
// This is a hack TODO: introduce types?
String left = this.left.getValue();
if (this.left.isAttribute()) {
left = Database.encode(left);
} else if (left.startsWith("'") == false) {
left = "CAST(" + left + " AS int)";
}
String right = this.right.getValue();
if (this.right.isAttribute()) {
right = Database.encode(right);
} else if (right.startsWith("'") == false) {
right = "CAST( " + right + " AS int)";
}
return left + " < " + right;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment