Skip to content

Commit 21cb0fd

Browse files
committed
🐛 fix query converter issue
1 parent 273bcd8 commit 21cb0fd

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

retrosheet/src/main/kotlin/com/github/theapache64/retrosheet/utils/TypeIdentifier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ object TypeIdentifier {
3131
}
3232

3333
fun isNumber(value: String): Boolean {
34-
return isDouble(value)
34+
return isDouble(value) || isInteger(value)
3535
}
3636
}

retrosheet/src/test/kotlin/com/github/theapache64/retrosheet/core/QueryConverterTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,17 @@ class QueryConverterTest {
4242
val actualOutput = QueryConverter(input, emptyMap(), paramMap).convert()
4343
actualOutput.should.equal("SELECT * WHERE foo = 'a' AND bar = 'b'")
4444
}
45+
46+
@Test
47+
fun `Strings are surrounded by single quotes and numbers are surrounded by nothing`() {
48+
val input =
49+
"SELECT * WHERE my_string = :my_string AND my_int = :my_int AND my_double = :my_double"
50+
val paramMap = mapOf(
51+
"my_string" to "com.truecaller",
52+
"my_int" to "3",
53+
"my_double" to "3.14"
54+
)
55+
val actualOutput = QueryConverter(input, emptyMap(), paramMap).convert()
56+
actualOutput.should.equal("SELECT * WHERE my_string = 'com.truecaller' AND my_int = 3 AND my_double = 3.14")
57+
}
4558
}

src/test/java/com/github/theapache64/retrosheet/integration/ReadTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ReadTest {
1515

1616
@Test
1717
fun `Reads data`() = runBlockingTest {
18-
notesApi.getNote("Do not delete this row")?.description.should
18+
notesApi.getNote("Do not delete this row").description.should
1919
.equal("This is custom desc")
2020
Unit
2121
}

0 commit comments

Comments
 (0)