Skip to content

Commit 8814e07

Browse files
committed
feat: support java.time.
1 parent d77dda5 commit 8814e07

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ void setObject(int parameterIndex, Object x)
121121
<T> T getObject(int columnIndex, Class<T> type)
122122
```
123123

124-
- TIMESTAMP_TZ and TIMESTAMP map to `OffsetDateTime`, `ZonedDateTime`, `Instant` (TIMESTAMP_TZ can return `OffsetDateTime` but not `ZonedDateTime`), and `LocalDateTime`.
124+
- TIMESTAMP_TZ and TIMESTAMP map to `OffsetDateTime`, `ZonedDateTime`, `Instant` and `LocalDateTime` (TIMESTAMP_TZ can return `OffsetDateTime` but not `ZonedDateTime`).
125125
- Date maps to `LocalDate`, and `getObject(..., LocalDate.class)` now mirrors what `getDate().toLocalDate()` returns.
126-
- When a TIMESTAMP literal omits a timezone, Databend uses the session timezone (not the JVM zone) when storing/returning dates on versions ≥0.4.3 driver + ≥1.2.844 server.
126+
- When parameters do not contain a timezone, Databend uses the session timezone (not the JVM zone) when storing/returning dates on databend-jdbc ≥ 0.4.3 AND databend-query ≥1.2.844.
127+
- `getString` return the display of default mapping type.
127128

128129
Timestamp/Date are also supported, note that:
129130

databend-jdbc/src/test/java/com/databend/jdbc/TestTypes.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void testSetTimestamp(boolean withTz)
159159
Timestamp timestamp = Timestamp.from(instant);
160160
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
161161

162-
// 1, 2, 3, 4: set use tz in var
162+
// 1, 2, 3, 4: same epoch, use tz in parameter,
163163
ps.setObject(1, offsetDateTime);
164164
ps.setInt(2, 1);
165165
ps.execute();
@@ -172,12 +172,11 @@ public void testSetTimestamp(boolean withTz)
172172
ps.setInt(2, 3);
173173
ps.execute();
174174

175-
// cal
176175
ps.setTimestamp(1, timestamp, cal);
177176
ps.setInt(2, 4);
178177
ps.execute();
179178

180-
// 5, 6: set use tz=UTC
179+
// 5, 6: same epoch, tz=UTC
181180
ps.setObject(1, instant);
182181
ps.setInt(2, 5);
183182
ps.execute();
@@ -186,7 +185,7 @@ public void testSetTimestamp(boolean withTz)
186185
ps.setInt(2, 6);
187186
ps.execute();
188187

189-
// 7: set use session tz
188+
// 7: diff epoch, set use session tz
190189
ps.setString(1, timeStringNoTZ);
191190
ps.setInt(2, 7);
192191
ps.execute();
@@ -200,7 +199,7 @@ public void testSetTimestamp(boolean withTz)
200199
exp = instant.atOffset(sessionOffset);
201200
}
202201

203-
// 1, 2, 3, 4: set use tz in var
202+
// 1, 2, 3, 4, 5: same epoch, use tz in parameter,
204203
r.next();
205204
Assert.assertEquals(exp, r.getObject(1, OffsetDateTime.class));
206205
if (!withTz) {

0 commit comments

Comments
 (0)