@@ -223,20 +223,21 @@ public class Sql92NodeStoreDialect implements NodeStoreSQLDialect {
223223 private static final String DELETE_USER_SUBSCRIPTIONS = "DELETE FROM \" subscriptions\" WHERE \" user\" = ?" ;
224224
225225 private static final String SELECT_NODE_THREADS =
226- "SELECT \" items.node\" , \" items.id\" , \" items.updated\" , \" items.xml\" , \" items.in_reply_to\" , " +
227- "\" threads.thread_id\" , \" threads.thread_updated\" FROM items," +
228- "(SELECT MAX(updated) AS thread_updated, thread_id FROM " +
229- "(SELECT node, updated, (CASE WHEN (in_reply_to IS NULL) THEN id ELSE in_reply_to END) AS thread_id FROM items) AS _items" +
230- "WHERE node = ? " +
231- "GROUP BY thread_id " +
232- "HAVING MAX(updated) < ? " +
233- "ORDER BY thread_updated DESC LIMIT ?) AS threads " +
234- "WHERE items.in_reply_to = threads.thread_id OR items.id = threads.thread_id " +
235- "ORDER BY threads.thread_updated DESC, items.updated;" ;
236-
237- private static final String COUNT_NODE_THREADS = "SELECT COUNT(DISTINCT _items.thread_id) " +
238- "FROM (SELECT node, (CASE WHEN (in_reply_to IS NULL) THEN id ELSE in_reply_to END) AS thread_id " +
239- "FROM items WHERE node = ?) AS _items;" ;
226+ "SELECT \" node\" , \" id\" , \" updated\" , \" xml\" , \" in_reply_to\" , " +
227+ "\" thread_id\" , \" thread_updated\" FROM \" items\" ," +
228+ "(SELECT MAX(\" updated\" ) AS \" thread_updated\" , \" thread_id\" FROM " +
229+ "(SELECT \" updated\" , " +
230+ "(CASE WHEN (\" in_reply_to\" IS NULL) THEN \" id\" ELSE \" in_reply_to\" END) AS \" thread_id\" " +
231+ "FROM \" items\" WHERE \" node\" = ?) AS \" _items\" " +
232+ "GROUP BY \" thread_id\" " +
233+ "HAVING MAX(\" updated\" ) < ? " +
234+ "ORDER BY \" thread_updated\" DESC LIMIT ?) AS \" threads\" " +
235+ "WHERE \" in_reply_to\" = \" thread_id\" OR \" id\" = \" thread_id\" " +
236+ "ORDER BY \" thread_updated\" DESC, \" updated\" " ;
237+
238+ private static final String COUNT_NODE_THREADS = "SELECT COUNT(DISTINCT \" thread_id\" ) " +
239+ "FROM (SELECT \" node\" , (CASE WHEN (\" in_reply_to\" IS NULL) THEN \" id\" ELSE \" in_reply_to\" END) AS \" thread_id\" " +
240+ "FROM \" items\" WHERE \" node\" = ?) AS \" _items\" " ;
240241
241242 @ Override
242243 public String insertNode () {
0 commit comments