Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order results from getColumns #1348

Merged
merged 19 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c97b863
Fix AEv2 tests exclude for reqExternalSetup and cleanup (#1247)
lilgreenbird Feb 5, 2020
54b5a19
Fix | Add null check for getObject() with LocalTime and LocalDate (#1…
peterbae Feb 8, 2020
672b7d6
added all AKV tests to use reqExternalSetup tag so they will be skipp…
lilgreenbird Feb 10, 2020
3c3331b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 25, 2020
e2c5640
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 26, 2020
aad6966
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 28, 2020
92bf04c
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 31, 2020
3ba5ab7
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 4, 2020
d20823d
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 7, 2020
4cc959f
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 29, 2020
7b301f8
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 30, 2020
56bcf13
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 7, 2020
744e0ca
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 12, 2020
df8fd41
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 19, 2020
652e68b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 26, 2020
d24c7e5
Merge remote-tracking branch 'upstream/dev' into columninfo
lilgreenbird May 26, 2020
37fd1a5
added order by
lilgreenbird May 29, 2020
f48473f
Merge remote-tracking branch 'upstream/dev' into columninfo
lilgreenbird Jun 10, 2020
3879bf8
review updates
lilgreenbird Jun 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix | Add null check for getObject() with LocalTime and LocalDate (#1250
)
  • Loading branch information
peterbae authored Feb 8, 2020
commit 54b5a194e5d46552419c86e0d1f8c800f42d3de8
Original file line number Diff line number Diff line change
Expand Up @@ -2394,12 +2394,16 @@ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
} else if (type == java.time.LocalDateTime.class || type == java.time.LocalDate.class
|| type == java.time.LocalTime.class) {
java.time.LocalDateTime ldt = getLocalDateTime(columnIndex);
if (type == java.time.LocalDateTime.class) {
returnValue = ldt;
} else if (type == java.time.LocalDate.class) {
returnValue = ldt.toLocalDate();
if (null == ldt) {
returnValue = null;
} else {
returnValue = ldt.toLocalTime();
if (type == java.time.LocalDateTime.class) {
returnValue = ldt;
} else if (type == java.time.LocalDate.class) {
returnValue = ldt.toLocalDate();
} else {
returnValue = ldt.toLocalTime();
}
}
} else if (type == java.time.OffsetDateTime.class) {
microsoft.sql.DateTimeOffset dateTimeOffset = getDateTimeOffset(columnIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.text.DateFormatSymbols;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.time.zone.ZoneOffsetTransition;
Expand Down Expand Up @@ -1821,6 +1823,28 @@ public void testGetLocalDateTimePriorGregorian() throws Exception {
}
}
}

@Test
public void testNullValuesWithGetObject() throws Exception {
String ldtTable = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("ldtTable"));
try (Connection conn = getConnection(); Statement st = conn.createStatement();) {
TestUtils.dropTableIfExists(ldtTable, st);
st.execute("CREATE TABLE " + ldtTable + " (c1 datetime2)");
st.execute("INSERT INTO " + ldtTable + " VALUES (NULL)");

try (ResultSet rs = st.executeQuery("SELECT c1 FROM " + ldtTable);) {
rs.next();
LocalDateTime ldtActual = rs.getObject(1, LocalDateTime.class);
assertEquals(ldtActual, null);
LocalTime ltActual = rs.getObject(1, LocalTime.class);
assertEquals(ltActual, null);
LocalDate ldActual = rs.getObject(1, LocalDate.class);
assertEquals(ldActual, null);
} finally {
TestUtils.dropTableIfExists(ldtTable, st);
}
}
}

/**
* Test example from https://github.com/microsoft/mssql-jdbc/issues/1143
Expand Down