|
2 | 2 |
|
3 | 3 | import java.math.BigDecimal; |
4 | 4 | import java.sql.Connection; |
5 | | -import java.sql.Statement; |
6 | 5 | import java.util.Optional; |
7 | 6 | import java.util.regex.Pattern; |
8 | 7 |
|
@@ -235,54 +234,14 @@ public static SQLite3Constant castToText(SQLite3Constant cons) { |
235 | 234 | return SQLite3Constant.createTextConstant("Inf"); |
236 | 235 | } else if (cons.asDouble() == Double.NEGATIVE_INFINITY) { |
237 | 236 | return SQLite3Constant.createTextConstant("-Inf"); |
| 237 | + } else { |
| 238 | + return null; |
238 | 239 | } |
239 | | - return castRealToText(cons); |
240 | | - // if (true) { |
241 | | - // throw new IgnoreMeException(); |
242 | | - // } |
243 | | - // NumberFormat fmt = NumberFormat.getInstance(); |
244 | | - // fmt.setGroupingUsed(false); |
245 | | - // fmt.setMaximumIntegerDigits(10); |
246 | | - // fmt.setMinimumFractionDigits(1); |
247 | | - // fmt.setRoundingMode(RoundingMode.UNNECESSARY); |
248 | | - // int digits; |
249 | | - // if (cons.asDouble() < 0) { |
250 | | - // digits = 15; |
251 | | - // } else { |
252 | | - // digits = 15; |
253 | | - // } |
254 | | - // fmt.setMaximumFractionDigits(digits); |
255 | | - // try { |
256 | | - // String s = fmt.format(cons.asDouble()); |
257 | | - // if (s.contentEquals("")) { |
258 | | - // throw new IgnoreMeException(); |
259 | | - // } |
260 | | - // return SQLite3Constant.createTextConstant(s); |
261 | | - // } catch (Exception e) { |
262 | | - // throw new IgnoreMeException(); |
263 | | - // } |
264 | 240 | } |
265 | 241 | if (cons.getDataType() == SQLite3DataType.INT) { |
266 | 242 | return SQLite3Constant.createTextConstant(String.valueOf(cons.asInt())); |
267 | 243 | } |
268 | | - // if (cons.getDataType() == SQLite3DataType.BINARY) { |
269 | | - // try { |
270 | | - // return SQLite3Constant.createTextConstant(new String(cons.asBinary(), "UTF-8").replaceAll("\\p{C}", "")); |
271 | | - // } catch (UnsupportedEncodingException e) { |
272 | | - // throw new AssertionError(e); |
273 | | - // } |
274 | | - // } |
275 | 244 | return null; |
276 | | - // throw new AssertionError(); |
277 | | - } |
278 | | - |
279 | | - private static synchronized SQLite3Constant castRealToText(SQLite3Constant cons) throws AssertionError { |
280 | | - try (Statement s = castDatabase.createStatement()) { |
281 | | - String castResult = s.executeQuery("SELECT CAST(" + cons.asDouble() + " AS TEXT)").getString(1); |
282 | | - return SQLite3Constant.createTextConstant(castResult); |
283 | | - } catch (Exception e) { |
284 | | - throw new AssertionError(e); |
285 | | - } |
286 | 245 | } |
287 | 246 |
|
288 | 247 | public static SQLite3Constant asBoolean(SQLite3Constant val) { |
|
0 commit comments