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
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from sql import Literal
|
|
||||||
from sql.aggregate import Count
|
from sql.aggregate import Count
|
||||||
|
|
||||||
from trytond.bus import Bus
|
from trytond.bus import Bus
|
||||||
@@ -149,7 +148,7 @@ class Notification(
|
|||||||
notification = cls.__table__()
|
notification = cls.__table__()
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
cursor.execute(*notification.select(
|
cursor.execute(*notification.select(
|
||||||
Count(Literal('*')),
|
Count(),
|
||||||
where=((notification.user == Transaction().user)
|
where=((notification.user == Transaction().user)
|
||||||
& notification.unread)))
|
& notification.unread)))
|
||||||
return cursor.fetchone()[0]
|
return cursor.fetchone()[0]
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class NotificationTestCase(TestCase):
|
|||||||
self.assertEqual(message.audience, 'public')
|
self.assertEqual(message.audience, 'public')
|
||||||
self.assertEqual(message.content, "Chat Message: Bar")
|
self.assertEqual(message.content, "Chat Message: Bar")
|
||||||
with Transaction().set_user(alice.id):
|
with Transaction().set_user(alice.id):
|
||||||
|
self.assertEqual(Notification.get_count(), 1)
|
||||||
notification, = Notification.get()
|
notification, = Notification.get()
|
||||||
self.assertEqual(notification, {
|
self.assertEqual(notification, {
|
||||||
'id': notification['id'],
|
'id': notification['id'],
|
||||||
|
|||||||
Reference in New Issue
Block a user