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:
@@ -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]
|
||||
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user