Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
real
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paolo Guagliardo
real
Commits
c882cb42
Commit
c882cb42
authored
2 months ago
by
Paolo Guagliardo
Browse files
Options
Downloads
Patches
Plain Diff
Fix evaluation of conditions with constants (WIP)
parent
c8f96f0f
Branches
feature/sqlite
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/uk/ac/ed/pguaglia/real/lang/Equality.java
+2
-2
2 additions, 2 deletions
src/main/java/uk/ac/ed/pguaglia/real/lang/Equality.java
src/main/java/uk/ac/ed/pguaglia/real/lang/LessThan.java
+13
-4
13 additions, 4 deletions
src/main/java/uk/ac/ed/pguaglia/real/lang/LessThan.java
with
15 additions
and
6 deletions
src/main/java/uk/ac/ed/pguaglia/real/lang/Equality.java
+
2
−
2
View file @
c882cb42
...
...
@@ -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
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/uk/ac/ed/pguaglia/real/lang/LessThan.java
+
13
−
4
View file @
c882cb42
...
...
@@ -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
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment