Do not use Literal to count in SQL

Following ce972acc1cf2, this conversion was missing and prevent psycopg 3 to
determine the data type.
This commit is contained in:
Cédric Krier
2026-03-24 18:25:19 +01:00
parent 475e68df76
commit fa9e60bb9c
2 changed files with 2 additions and 2 deletions
+1 -2
View File
@@ -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]
+1
View File
@@ -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'],