From cf90533b6c96f93b531f7bfd5d6bf983189a9992 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 19 Mar 2025 20:31:42 -0400 Subject: [PATCH] ssb: Make these queries match the index more pedandically, if only for consistency. --- src/ssb.db.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ssb.db.c b/src/ssb.db.c index 0d4d3375..153df218 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -1468,9 +1468,9 @@ static void _populate_follows_and_blocks(tf_ssb_t* ssb, following_t* entry, foll sqlite3* db = tf_ssb_acquire_db_reader(ssb); sqlite3_stmt* statement = NULL; if (sqlite3_prepare(db, - "SELECT json_extract(content, '$.contact') AS contact, json_extract(content, '$.following'), json_extract(content, '$.blocking') " + "SELECT content ->> '$.contact' AS contact, content ->> '$.following', content ->> '$.blocking' " "FROM messages " - "WHERE contact IS NOT NULL AND author = ? AND json_extract(content, '$.type') = 'contact' " + "WHERE contact IS NOT NULL AND author = ? AND content ->> '$.type' = 'contact' " "ORDER BY sequence", -1, &statement, NULL) == SQLITE_OK) { @@ -2306,7 +2306,7 @@ const char* tf_ssb_db_get_profile_name(sqlite3* db, const char* id) if (sqlite3_prepare(db, "SELECT name FROM (SELECT messages.author, RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank, " "messages.content ->> 'name' AS name FROM messages WHERE messages.author = ? " - "AND json_extract(messages.content, '$.type') = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) " + "AND messages.content ->> '$.type' = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) " "WHERE author_rank = 1", -1, &statement, NULL) == SQLITE_OK) { @@ -2472,7 +2472,7 @@ tf_ssb_identity_info_t* tf_ssb_db_get_identity_info(tf_ssb_t* ssb, const char* u " JOIN identities ON messages.author = ('@' || identities.public_key) " " WHERE " " (identities.user = ? OR identities.public_key = ?) AND " - " json_extract(messages.content, '$.type') = 'about' AND " + " messages.content ->> '$.type' = 'about' AND " " content ->> 'about' = messages.author AND name IS NOT NULL) " "WHERE author_rank = 1 ", -1, &statement, NULL);