change in confirm mechanism
This commit is contained in:
+7
-1
@@ -181,6 +181,12 @@ pub async fn list_note_stats(
|
|||||||
DatabaseKind::Postgres => "$1",
|
DatabaseKind::Postgres => "$1",
|
||||||
DatabaseKind::Sqlite | DatabaseKind::MySql => "?",
|
DatabaseKind::Sqlite | DatabaseKind::MySql => "?",
|
||||||
};
|
};
|
||||||
|
// PostgreSQL promotes SUM(BIGINT) to NUMERIC. sqlx::Any cannot decode the
|
||||||
|
// database-specific NUMERIC type, so normalize the aggregate to BIGINT.
|
||||||
|
let file_size_sum = match pool.kind() {
|
||||||
|
DatabaseKind::Postgres => "COALESCE(SUM(f.size_bytes), 0)::BIGINT",
|
||||||
|
DatabaseKind::Sqlite | DatabaseKind::MySql => "COALESCE(SUM(f.size_bytes), 0)",
|
||||||
|
};
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"SELECT n.id AS note_id, \
|
"SELECT n.id AS note_id, \
|
||||||
((SELECT COUNT(DISTINCT r.author) FROM note_revisions r \
|
((SELECT COUNT(DISTINCT r.author) FROM note_revisions r \
|
||||||
@@ -189,7 +195,7 @@ pub async fn list_note_stats(
|
|||||||
SELECT 1 FROM note_revisions r WHERE r.note_id = n.id AND r.author = n.created_by\
|
SELECT 1 FROM note_revisions r WHERE r.note_id = n.id AND r.author = n.created_by\
|
||||||
) THEN 1 ELSE 0 END) AS participant_count, \
|
) THEN 1 ELSE 0 END) AS participant_count, \
|
||||||
(SELECT COUNT(*) FROM note_files f WHERE f.note_id = n.id) AS file_count, \
|
(SELECT COUNT(*) FROM note_files f WHERE f.note_id = n.id) AS file_count, \
|
||||||
(SELECT COALESCE(SUM(f.size_bytes), 0) FROM note_files f WHERE f.note_id = n.id) AS file_size_bytes, \
|
(SELECT {file_size_sum} FROM note_files f WHERE f.note_id = n.id) AS file_size_bytes, \
|
||||||
(SELECT COUNT(*) FROM note_revisions r WHERE r.note_id = n.id) AS revision_count \
|
(SELECT COUNT(*) FROM note_revisions r WHERE r.note_id = n.id) AS revision_count \
|
||||||
FROM notes n WHERE n.workspace_id = {placeholder}"
|
FROM notes n WHERE n.workspace_id = {placeholder}"
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user