From fa9e60bb9c6faac8fc27199ee01eda1da3813e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Mar 2026 18:25:19 +0100 Subject: [PATCH] Do not use Literal to count in SQL Following ce972acc1cf2, this conversion was missing and prevent psycopg 3 to determine the data type. --- trytond/trytond/res/notification.py | 3 +-- trytond/trytond/tests/test_chat.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/res/notification.py b/trytond/trytond/res/notification.py index 3f072a68b4..9492c7cabc 100644 --- a/trytond/trytond/res/notification.py +++ b/trytond/trytond/res/notification.py @@ -4,7 +4,6 @@ import json from collections import defaultdict -from sql import Literal from sql.aggregate import Count from trytond.bus import Bus @@ -149,7 +148,7 @@ class Notification( notification = cls.__table__() cursor = Transaction().connection.cursor() cursor.execute(*notification.select( - Count(Literal('*')), + Count(), where=((notification.user == Transaction().user) & notification.unread))) return cursor.fetchone()[0] diff --git a/trytond/trytond/tests/test_chat.py b/trytond/trytond/tests/test_chat.py index ece37c9106..25f34b6c28 100644 --- a/trytond/trytond/tests/test_chat.py +++ b/trytond/trytond/tests/test_chat.py @@ -49,6 +49,7 @@ class NotificationTestCase(TestCase): self.assertEqual(message.audience, 'public') self.assertEqual(message.content, "Chat Message: Bar") with Transaction().set_user(alice.id): + self.assertEqual(Notification.get_count(), 1) notification, = Notification.get() self.assertEqual(notification, { 'id': notification['id'],