Skip to content

Commit

Permalink
simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz committed Jun 10, 2024
1 parent 04b44be commit a3d2f39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.TimeZone;
import raw.client.api.LocationDescription;
import raw.runtime.truffle.runtime.exceptions.rdbms.JdbcExceptionHandler;
import raw.runtime.truffle.runtime.exceptions.rdbms.JdbcReaderRawTruffleException;
Expand All @@ -40,10 +37,6 @@ public class JdbcQuery {
private final JdbcExceptionHandler exceptionHandler;
private final String url;

// required to extract time and timestamp values
private final ZoneId timezone = ZoneId.of("UTC");
private final Calendar zonedCalendar = Calendar.getInstance(TimeZone.getTimeZone(timezone));

@TruffleBoundary
public JdbcQuery(
LocationDescription locationDescription,
Expand Down Expand Up @@ -195,7 +188,7 @@ TimeObject getTime(String colName, Node node) {
@TruffleBoundary
TimestampObject getTimestamp(String colName, Node node) {
try {
java.sql.Timestamp sqlTimestamp = rs.getTimestamp(colName, zonedCalendar);
java.sql.Timestamp sqlTimestamp = rs.getTimestamp(colName);
return new TimestampObject(sqlTimestamp.toLocalDateTime());
} catch (SQLException e) {
throw exceptionHandler.columnParseError(e, colName, node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import raw.client.api._
import raw.client.sql.antlr4._

import java.sql.{Connection, ResultSet, ResultSetMetaData}
import java.time.{LocalTime, ZoneId}
import java.util.{Calendar, TimeZone}
import java.time.LocalTime
import scala.collection.mutable

/* This class is wrapping the PreparedStatement class from the JDBC API.
Expand Down Expand Up @@ -548,9 +547,6 @@ class NamedParametersPreparedStatement(conn: Connection, parsedTree: ParseProgra
}
}

private val timezone = ZoneId.of("UTC")
private val zonedCalendar = Calendar.getInstance(TimeZone.getTimeZone(timezone))

private def getDefaultValue(rs: ResultSet, postgresType: PostgresType): DefaultValue = {
assert(rs.next(), "rs.next() was false")
val attempt = postgresType.jdbcType match {
Expand All @@ -561,8 +557,8 @@ class NamedParametersPreparedStatement(conn: Connection, parsedTree: ParseProgra
case java.sql.Types.FLOAT => RawFloat(rs.getFloat(1))
case java.sql.Types.DOUBLE => RawDouble(rs.getDouble(1))
case java.sql.Types.DATE => RawDate(rs.getDate(1).toLocalDate)
case java.sql.Types.TIME => RawTime(LocalTime.ofNanoOfDay(rs.getTime(1, zonedCalendar).getTime * 1000000))
case java.sql.Types.TIMESTAMP => RawTimestamp(rs.getTimestamp(1, zonedCalendar).toLocalDateTime)
case java.sql.Types.TIME => RawTime(LocalTime.ofNanoOfDay(rs.getTime(1).getTime * 1000000))
case java.sql.Types.TIMESTAMP => RawTimestamp(rs.getTimestamp(1).toLocalDateTime)
case java.sql.Types.BOOLEAN => RawBool(rs.getBoolean(1))
case java.sql.Types.VARCHAR => RawString(rs.getString(1))
}
Expand Down

0 comments on commit a3d2f39

Please sign in to comment.