Skip to content

Commit

Permalink
🐛 fix query converter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
theapache64 committed Oct 18, 2021
1 parent 273bcd8 commit 21cb0fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ object TypeIdentifier {
}

fun isNumber(value: String): Boolean {
return isDouble(value)
return isDouble(value) || isInteger(value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@ class QueryConverterTest {
val actualOutput = QueryConverter(input, emptyMap(), paramMap).convert()
actualOutput.should.equal("SELECT * WHERE foo = 'a' AND bar = 'b'")
}

@Test
fun `Strings are surrounded by single quotes and numbers are surrounded by nothing`() {
val input =
"SELECT * WHERE my_string = :my_string AND my_int = :my_int AND my_double = :my_double"
val paramMap = mapOf(
"my_string" to "com.truecaller",
"my_int" to "3",
"my_double" to "3.14"
)
val actualOutput = QueryConverter(input, emptyMap(), paramMap).convert()
actualOutput.should.equal("SELECT * WHERE my_string = 'com.truecaller' AND my_int = 3 AND my_double = 3.14")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReadTest {

@Test
fun `Reads data`() = runBlockingTest {
notesApi.getNote("Do not delete this row")?.description.should
notesApi.getNote("Do not delete this row").description.should
.equal("This is custom desc")
Unit
}
Expand Down

0 comments on commit 21cb0fd

Please sign in to comment.