Skip to content

Commit

Permalink
Fixed the NPE of TableDeviceLastEntry
Browse files Browse the repository at this point in the history
(cherry picked from commit 52da698)
  • Loading branch information
Caideyipi authored and JackieTien97 committed Jan 25, 2025
1 parent eceebd2 commit 924a93b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,28 @@ public void testRangeDelete() throws SQLException {
cleanData(4);
}

@Test
public void testSuccessfullyInvalidateCache() throws SQLException {
prepareData(4, 1);
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
statement.execute("use test");
statement.executeQuery(
"SELECT last(time), last_by(s0,time), last_by(s1,time), last_by(s2,time), last_by(s3,time), last_by(s4,time) FROM vehicle4 where deviceId = 'd0'");

// [1, 400] -> [1, 299]
statement.execute("DELETE FROM vehicle4 WHERE time >= 300");
try (ResultSet set = statement.executeQuery("SELECT s0 FROM vehicle4")) {
int cnt = 0;
while (set.next()) {
cnt++;
}
assertEquals(299, cnt);
}
}
cleanData(4);
}

@Test
public void testFullDeleteWithoutWhereClause() throws SQLException {
prepareData(5, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int tryUpdate(
"",
(time, tvPair) ->
tvPair.getTimestamp() < finalLastTime
? new TimeValuePair(finalLastTime, null)
? new TimeValuePair(finalLastTime, EMPTY_PRIMITIVE_TYPE)
: tvPair);
return diff.get();
}
Expand Down

0 comments on commit 924a93b

Please sign in to comment.