Skip to content

Commit dc88dd3

Browse files
committed
Fix database calls after corruption recovery
1 parent 61c77d1 commit dc88dd3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStore.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,16 +869,23 @@ public CloseableIterator<NodeItem> getNodeItems(String nodeId, String afterItemI
869869
}
870870

871871
String countSQL = "";
872-
873872
if (count > -1) {
874873
countSQL = " OFFSET 0 LIMIT " + count;
875874
} else if (count < -1) {
876875
throw new IllegalArgumentException("Invalid value for parameter count: " + count);
877876
}
878-
877+
878+
String parentOnlySubstitution = "";
879+
if (parentOnly) {
880+
parentOnlySubstitution = " AND \"in_reply_to\" IS NOT NULL ";
881+
}
882+
883+
String query = null;
879884
try {
880885
if (afterItem == null) {
881-
stmt = conn.prepareStatement(dialect.selectItemsForNode() + countSQL);
886+
query = dialect.selectItemsForNode()
887+
.replace("%parentOnly%", parentOnlySubstitution) + countSQL;
888+
stmt = conn.prepareStatement(query);
882889
stmt.setString(1, nodeId);
883890

884891
java.sql.ResultSet rs = stmt.executeQuery();
@@ -893,7 +900,9 @@ public NodeItem convertRow(java.sql.ResultSet rs) throws SQLException {
893900
}
894901
});
895902
} else {
896-
stmt = conn.prepareStatement(dialect.selectItemsForNodeBeforeDate() + countSQL);
903+
query = dialect.selectItemsForNodeBeforeDate()
904+
.replace("%parentOnly%", parentOnlySubstitution) + countSQL;
905+
stmt = conn.prepareStatement(query);
897906
stmt.setString(1, nodeId);
898907
stmt.setTimestamp(2, new java.sql.Timestamp(afterItem.getUpdated().getTime()));
899908
stmt.setTimestamp(3, new java.sql.Timestamp(afterItem.getUpdated().getTime()));

0 commit comments

Comments
 (0)