在 Django 中,查询是用“::text”生成的。铸造,我怎样才能将其关闭?
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))
我正在连接到不喜欢 ::text 转换的 Vertica 数据库。有办法禁用这个吗?
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 ))';
They code that generated this query is
Notification.objects.filter(Q(firstnotified__range=(beginstring, endstring)),Q(instance__contains=i)|Q(elementname=i)|Q(troubleticketid__contains=i)|Q(userdefined2=i))
I'm connecting to a Vertica database that doesn't like the ::text casting. Is there a way to disable this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您实现自己的扩展
PostgreSQL
后端的数据库后端,则可以更改它。::text
被硬编码在DatabaseOperations
类的lookup_cast
方法中。来源: http://code.djangoproject .com/browser/django/trunk/django/db/backends/postgresql/operations.py#L60
If you implement your own database backend that extends the
PostgreSQL
backend than you can change it.the
::text
is hardcoded in thelookup_cast
method in theDatabaseOperations
class.Source: http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/operations.py#L60