本文整理汇总了Python中django.db.connection.features方法的典型用法代码示例。如果您正苦于以下问题:Python connection.features方法的具体用法?Python connection.features怎么用?Python connection.features使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.connection
的用法示例。
在下文中一共展示了connection.features方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _reset_sequences
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _reset_sequences(self, db_name):
conn = connections[db_name]
if conn.features.supports_sequence_reset:
sql_list = conn.ops.sequence_reset_by_name_sql(
no_style(), conn.introspection.sequence_list())
if sql_list:
with transaction.atomic(using=db_name):
cursor = conn.cursor()
for sql in sql_list:
cursor.execute(sql)
示例2: connections_support_transactions
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def connections_support_transactions():
"""
Returns True if all connections support transactions.
"""
return all(conn.features.supports_transactions
for conn in connections.all())
示例3: skipIfDBFeature
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipIfDBFeature(*features):
"""
Skip a test if a database has at least one of the named features.
"""
return _deferredSkip(
lambda: any(getattr(connection.features, feature, False) for feature in features),
"Database has feature(s) %s" % ", ".join(features)
)
示例4: skipUnlessDBFeature
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessDBFeature(*features):
"""
Skip a test unless a database has all the named features.
"""
return _deferredSkip(
lambda: not all(getattr(connection.features, feature, False) for feature in features),
"Database doesn't support feature(s): %s" % ", ".join(features)
)
示例5: can_migrate
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def can_migrate(self, connection):
"""
Return True if the model can/should be migrated on the `connection`.
`connection` can be either a real connection or a connection alias.
"""
if self.proxy or self.swapped or not self.managed:
return False
if isinstance(connection, str):
connection = connections[connection]
if self.required_db_vendor:
return self.required_db_vendor == connection.vendor
if self.required_db_features:
return all(getattr(connection.features, feat, False)
for feat in self.required_db_features)
return True
示例6: connections_support_transactions
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def connections_support_transactions():
"""Return True if all connections support transactions."""
return all(conn.features.supports_transactions for conn in connections.all())
示例7: _should_check_constraints
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _should_check_constraints(self, connection):
return (
connection.features.can_defer_constraint_checks and
not connection.needs_rollback and connection.is_usable()
)
示例8: skipIfDBFeature
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipIfDBFeature(*features):
"""Skip a test if a database has at least one of the named features."""
return _deferredSkip(
lambda: any(getattr(connection.features, feature, False) for feature in features),
"Database has feature(s) %s" % ", ".join(features)
)
示例9: skipUnlessAnyDBFeature
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessAnyDBFeature(*features):
"""Skip a test unless a database has any of the named features."""
return _deferredSkip(
lambda: not any(getattr(connection.features, feature, False) for feature in features),
"Database doesn't support any of the feature(s): %s" % ", ".join(features)
)
示例10: test_mock_django_connection
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def test_mock_django_connection(self, mock_handler):
is_foo_before = bool(getattr(connection.features, 'is_foo', False))
mock_django_connection(disabled_features=['is_foo'])
is_foo_after = bool(getattr(connection.features, 'is_foo', False))
self.assertTrue(is_foo_before)
self.assertFalse(is_foo_after)
# noinspection PyUnresolvedReferences,PyStatementEffect
示例11: _reset_sequences
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _reset_sequences(self, db_name):
conn = connections[db_name]
if conn.features.supports_sequence_reset:
sql_list = conn.ops.sequence_reset_by_name_sql(
no_style(), conn.introspection.sequence_list())
if sql_list:
with transaction.atomic(using=db_name):
with conn.cursor() as cursor:
for sql in sql_list:
cursor.execute(sql)
示例12: can_migrate
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def can_migrate(self, connection):
"""
Return True if the model can/should be migrated on the `connection`.
`connection` can be either a real connection or a connection alias.
"""
if self.proxy or self.swapped or not self.managed:
return False
if isinstance(connection, six.string_types):
connection = connections[connection]
if self.required_db_vendor:
return self.required_db_vendor == connection.vendor
if self.required_db_features:
return all(getattr(connection.features, feat, False)
for feat in self.required_db_features)
return True
示例13: skipUnlessAnyDBFeature
# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessAnyDBFeature(*features):
"""
Skip a test unless a database has any of the named features.
"""
return _deferredSkip(
lambda: not any(getattr(connection.features, feature, False) for feature in features),
"Database doesn't support any of the feature(s): %s" % ", ".join(features)
)