本文整理汇总了Python中django.db.connection.data_type_check_constraints方法的典型用法代码示例。如果您正苦于以下问题:Python connection.data_type_check_constraints方法的具体用法?Python connection.data_type_check_constraints怎么用?Python connection.data_type_check_constraints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.connection
的用法示例。
在下文中一共展示了connection.data_type_check_constraints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: db_parameters
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import data_type_check_constraints [as 别名]
def db_parameters(self, connection):
"""
Extension of db_type(), providing a range of different return
values (type, checks).
This will look at db_type(), allowing custom model fields to override it.
"""
data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
type_string = self.db_type(connection)
try:
check_string = connection.data_type_check_constraints[self.get_internal_type()] % data
except KeyError:
check_string = None
return {
"type": type_string,
"check": check_string,
}
示例2: db_check
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import data_type_check_constraints [as 别名]
def db_check(self, connection):
"""
Return the database column check constraint for this field, for the
provided connection. Works the same way as db_type() for the case that
get_internal_type() does not map to a preexisting model field.
"""
data = self.db_type_parameters(connection)
try:
return connection.data_type_check_constraints[self.get_internal_type()] % data
except KeyError:
return None
示例3: db_check
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import data_type_check_constraints [as 别名]
def db_check(self, connection):
"""
Return the database column check constraint for this field, for the
provided connection. Works the same way as db_type() for the case that
get_internal_type() does not map to a preexisting model field.
"""
data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
try:
return connection.data_type_check_constraints[self.get_internal_type()] % data
except KeyError:
return None