В Django запросы генерируются с помощью Casting «:: Text», как я могу это выключить?

StackOverflow https://stackoverflow.com/questions/4589578

  •  14-10-2019
  •  | 
  •  

Вопрос

SELECT "snore_notification"."id", "snore_notification"."acknowledged",
"snore_notification"."active", "snore_notification"."classname", 
"snore_notification"."elementclass", "snore_notification"."elementname", 
"snore_notification"."event", "snore_notification"."eventtext", 
"snore_notification"."firstnotified", "snore_notification"."lastnotified", 
"snore_notification"."lastcleared", "snore_notification"."lastchanged", 
"snore_notification"."inserttime", "snore_notification"."instance", 
"snore_notification"."impact", "snore_notification"."isroot", 
"snore_notification"."isproblem", "snore_notification"."name", 
"snore_notification"."notificationtype", "snore_notification"."owner", 
"snore_notification"."severity", "snore_notification"."sourcedomain", 
"snore_notification"."troubleticketid", "snore_notification"."userdefined1",
"snore_notification"."userdefined2", "snore_notification"."userdefined3", 
"snore_notification"."userdefined4", "snore_notification"."userdefined5", 
"snore_notification"."userdefined6", "snore_notification"."userdefined7", 
"snore_notification"."userdefined8", "snore_notification"."userdefined9", 
"snore_notification"."userdefined10", "snore_notification"."instancedisplayname", 
"snore_notification"."counts" FROM "snore_notification" WHERE 
("snore_notification"."firstnotified" BETWEEN 2011-01-03 00:00:00 and 2011-01-03 
23:59:59 AND ("snore_notification"."instance"::text LIKE %OPEN% OR 
"snore_notification"."elementname" = OPEN OR 
"snore_notification"."troubleticketid"::text LIKE %OPEN% OR 
"snore_notification"."userdefined2" = OPEN ))';

Они кодируют этот запрос

Notification.objects.filter(Q(firstnotified__range=(beginstring,  endstring)),Q(instance__contains=i)|Q(elementname=i)|Q(troubleticketid__contains=i)|Q(userdefined2=i))

Я подключаюсь к базе данных Vertica, которая не любит :: Текстовое литье. Есть ли способ отключить это?

Это было полезно?

Решение

Если вы реализуете свой собственный бэкэнд базы данных, который расширяет PostgreSQL Бэкэнд, чем вы можете изменить.

а ::text жестко кодируется в lookup_cast Метод в DatabaseOperations учебный класс.

Источник: http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/operations.py#l60

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top