mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 20:48:27 +00:00
Really limit the number of rows that can be joined from parts.
Fixes #4299 Fixes #4298 // FREEBIE
This commit is contained in:
parent
a64dba8a7e
commit
f714f5b572
@ -309,7 +309,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
|
||||
private Cursor rawQuery(@NonNull String where, @Nullable String[] arguments) {
|
||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||
return database.rawQuery("SELECT DISTINCT " + Util.join(MMS_PROJECTION, ",") +
|
||||
return database.rawQuery("SELECT " + Util.join(MMS_PROJECTION, ",") +
|
||||
" FROM " + MmsDatabase.TABLE_NAME + " LEFT OUTER JOIN " + AttachmentDatabase.TABLE_NAME +
|
||||
" ON (" + MmsDatabase.TABLE_NAME + "." + MmsDatabase.ID + " = " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.MMS_ID + ")" +
|
||||
" WHERE " + where, arguments);
|
||||
|
@ -167,8 +167,15 @@ public class MmsSmsDatabase extends Database {
|
||||
mmsQueryBuilder.setDistinct(true);
|
||||
smsQueryBuilder.setDistinct(true);
|
||||
|
||||
mmsQueryBuilder.setTables(MmsDatabase.TABLE_NAME + " LEFT OUTER JOIN " + AttachmentDatabase.TABLE_NAME + " ON (" + MmsDatabase.TABLE_NAME + "." + MmsDatabase.ID + " = " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.MMS_ID + ")");
|
||||
smsQueryBuilder.setTables(SmsDatabase.TABLE_NAME);
|
||||
mmsQueryBuilder.setTables(MmsDatabase.TABLE_NAME + " LEFT OUTER JOIN " +
|
||||
AttachmentDatabase.TABLE_NAME +
|
||||
" ON " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.ROW_ID + " = " +
|
||||
" (SELECT " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.ROW_ID +
|
||||
" FROM " + AttachmentDatabase.TABLE_NAME + " WHERE " +
|
||||
AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.MMS_ID + " = " +
|
||||
MmsDatabase.TABLE_NAME + "." + MmsDatabase.ID + " LIMIT 1)");
|
||||
|
||||
|
||||
Set<String> mmsColumnsPresent = new HashSet<>();
|
||||
mmsColumnsPresent.add(MmsSmsColumns.ID);
|
||||
@ -222,7 +229,6 @@ public class MmsSmsDatabase extends Database {
|
||||
String unionQuery = unionQueryBuilder.buildUnionQuery(new String[] {smsSubQuery, mmsSubQuery}, order, limit);
|
||||
|
||||
SQLiteQueryBuilder outerQueryBuilder = new SQLiteQueryBuilder();
|
||||
outerQueryBuilder.setDistinct(true);
|
||||
outerQueryBuilder.setTables("(" + unionQuery + ")");
|
||||
|
||||
String query = outerQueryBuilder.buildQuery(projection, null, null, null, null, null, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user