當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.DEFAULT_INDEX_TABLESPACE屬性代碼示例

本文整理匯總了Python中django.conf.settings.DEFAULT_INDEX_TABLESPACE屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.DEFAULT_INDEX_TABLESPACE屬性的具體用法?Python settings.DEFAULT_INDEX_TABLESPACE怎麽用?Python settings.DEFAULT_INDEX_TABLESPACE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.DEFAULT_INDEX_TABLESPACE屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_db_tablespace

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def test_db_tablespace(self):
        with connection.schema_editor() as editor:
            # Index with db_tablespace attribute.
            for fields in [
                # Field with db_tablespace specified on model.
                ['shortcut'],
                # Field without db_tablespace specified on model.
                ['author'],
                # Multi-column with db_tablespaces specified on model.
                ['shortcut', 'isbn'],
                # Multi-column without db_tablespace specified on model.
                ['title', 'author'],
            ]:
                with self.subTest(fields=fields):
                    index = models.Index(fields=fields, db_tablespace='idx_tbls2')
                    self.assertIn('"idx_tbls2"', str(index.create_sql(Book, editor)).lower())
            # Indexes without db_tablespace attribute.
            for fields in [['author'], ['shortcut', 'isbn'], ['title', 'author']]:
                with self.subTest(fields=fields):
                    index = models.Index(fields=fields)
                    # The DEFAULT_INDEX_TABLESPACE setting can't be tested
                    # because it's evaluated when the model class is defined.
                    # As a consequence, @override_settings doesn't work.
                    if settings.DEFAULT_INDEX_TABLESPACE:
                        self.assertIn(
                            '"%s"' % settings.DEFAULT_INDEX_TABLESPACE,
                            str(index.create_sql(Book, editor)).lower()
                        )
                    else:
                        self.assertNotIn('TABLESPACE', str(index.create_sql(Book, editor)))
            # Field with db_tablespace specified on the model and an index
            # without db_tablespace.
            index = models.Index(fields=['shortcut'])
            self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower()) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:36,代碼來源:tests.py

示例2: sql_for_index

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def sql_for_index(model):
    return '\n'.join(str(sql) for sql in connection.schema_editor()._model_indexes_sql(model))


# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings
# because they're evaluated when the model class is defined. As a consequence,
# @override_settings doesn't work, and the tests depend 
開發者ID:nesdis,項目名稱:djongo,代碼行數:9,代碼來源:test_tablespaces.py

示例3: test_tablespace_for_model

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def test_tablespace_for_model(self):
        sql = sql_for_table(Scientist).lower()
        if settings.DEFAULT_INDEX_TABLESPACE:
            # 1 for the table
            self.assertNumContains(sql, 'tbl_tbsp', 1)
            # 1 for the index on the primary key
            self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1)
        else:
            # 1 for the table + 1 for the index on the primary key
            self.assertNumContains(sql, 'tbl_tbsp', 2) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:12,代碼來源:test_tablespaces.py

示例4: test_tablespace_for_indexed_field

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def test_tablespace_for_indexed_field(self):
        sql = sql_for_table(Article).lower()
        if settings.DEFAULT_INDEX_TABLESPACE:
            # 1 for the table
            self.assertNumContains(sql, 'tbl_tbsp', 1)
            # 1 for the primary key + 1 for the index on code
            self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 2)
        else:
            # 1 for the table + 1 for the primary key + 1 for the index on code
            self.assertNumContains(sql, 'tbl_tbsp', 3)

        # 1 for the index on reference
        self.assertNumContains(sql, 'idx_tbsp', 1) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:15,代碼來源:test_tablespaces.py

示例5: test_tablespace_for_many_to_many_field

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def test_tablespace_for_many_to_many_field(self):
        sql = sql_for_table(Authors).lower()
        # The join table of the ManyToManyField goes to the model's tablespace,
        # and its indexes too, unless DEFAULT_INDEX_TABLESPACE is set.
        if settings.DEFAULT_INDEX_TABLESPACE:
            # 1 for the table
            self.assertNumContains(sql, 'tbl_tbsp', 1)
            # 1 for the primary key
            self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1)
        else:
            # 1 for the table + 1 for the index on the primary key
            self.assertNumContains(sql, 'tbl_tbsp', 2)
        self.assertNumContains(sql, 'idx_tbsp', 0)

        sql = sql_for_index(Authors).lower()
        # The ManyToManyField declares no db_tablespace, its indexes go to
        # the model's tablespace, unless DEFAULT_INDEX_TABLESPACE is set.
        if settings.DEFAULT_INDEX_TABLESPACE:
            self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 2)
        else:
            self.assertNumContains(sql, 'tbl_tbsp', 2)
        self.assertNumContains(sql, 'idx_tbsp', 0)

        sql = sql_for_table(Reviewers).lower()
        # The join table of the ManyToManyField goes to the model's tablespace,
        # and its indexes too, unless DEFAULT_INDEX_TABLESPACE is set.
        if settings.DEFAULT_INDEX_TABLESPACE:
            # 1 for the table
            self.assertNumContains(sql, 'tbl_tbsp', 1)
            # 1 for the primary key
            self.assertNumContains(sql, settings.DEFAULT_INDEX_TABLESPACE, 1)
        else:
            # 1 for the table + 1 for the index on the primary key
            self.assertNumContains(sql, 'tbl_tbsp', 2)
        self.assertNumContains(sql, 'idx_tbsp', 0)

        sql = sql_for_index(Reviewers).lower()
        # The ManyToManyField declares db_tablespace, its indexes go there.
        self.assertNumContains(sql, 'tbl_tbsp', 0)
        self.assertNumContains(sql, 'idx_tbsp', 2) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:42,代碼來源:test_tablespaces.py

示例6: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def __init__(self, verbose_name=None, name=None, primary_key=False,
            max_length=None, unique=False, blank=False, null=False,
            db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
            serialize=True, unique_for_date=None, unique_for_month=None,
            unique_for_year=None, choices=None, help_text='', db_column=None,
            db_tablespace=None, auto_created=False, validators=[],
            error_messages=None):
        self.name = name
        self.verbose_name = verbose_name  # May be set by set_attributes_from_name
        self._verbose_name = verbose_name  # Store original for deconstruction
        self.primary_key = primary_key
        self.max_length, self._unique = max_length, unique
        self.blank, self.null = blank, null
        self.rel = rel
        self.is_relation = self.rel is not None
        self.default = default
        self.editable = editable
        self.serialize = serialize
        self.unique_for_date = unique_for_date
        self.unique_for_month = unique_for_month
        self.unique_for_year = unique_for_year
        self._choices = choices or []
        self.help_text = help_text
        self.db_column = db_column
        self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
        self.auto_created = auto_created

        # Set db_index to True if the field has a relationship and doesn't
        # explicitly set db_index.
        self.db_index = db_index

        # Adjust the appropriate creation counter, and save our local copy.
        if auto_created:
            self.creation_counter = Field.auto_creation_counter
            Field.auto_creation_counter -= 1
        else:
            self.creation_counter = Field.creation_counter
            Field.creation_counter += 1

        self._validators = validators  # Store for deconstruction later

        messages = {}
        for c in reversed(self.__class__.__mro__):
            messages.update(getattr(c, 'default_error_messages', {}))
        messages.update(error_messages or {})
        self._error_messages = error_messages  # Store for deconstruction later
        self.error_messages = messages 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:49,代碼來源:__init__.py

示例7: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def __init__(self, verbose_name=None, name=None, primary_key=False,
                 max_length=None, unique=False, blank=False, null=False,
                 db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
                 serialize=True, unique_for_date=None, unique_for_month=None,
                 unique_for_year=None, choices=None, help_text='', db_column=None,
                 db_tablespace=None, auto_created=False, validators=(),
                 error_messages=None):
        self.name = name
        self.verbose_name = verbose_name  # May be set by set_attributes_from_name
        self._verbose_name = verbose_name  # Store original for deconstruction
        self.primary_key = primary_key
        self.max_length, self._unique = max_length, unique
        self.blank, self.null = blank, null
        self.remote_field = rel
        self.is_relation = self.remote_field is not None
        self.default = default
        self.editable = editable
        self.serialize = serialize
        self.unique_for_date = unique_for_date
        self.unique_for_month = unique_for_month
        self.unique_for_year = unique_for_year
        if isinstance(choices, collections.Iterator):
            choices = list(choices)
        self.choices = choices or []
        self.help_text = help_text
        self.db_index = db_index
        self.db_column = db_column
        self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
        self.auto_created = auto_created

        # Adjust the appropriate creation counter, and save our local copy.
        if auto_created:
            self.creation_counter = Field.auto_creation_counter
            Field.auto_creation_counter -= 1
        else:
            self.creation_counter = Field.creation_counter
            Field.creation_counter += 1

        self._validators = list(validators)  # Store for deconstruction later

        messages = {}
        for c in reversed(self.__class__.__mro__):
            messages.update(getattr(c, 'default_error_messages', {}))
        messages.update(error_messages or {})
        self._error_messages = error_messages  # Store for deconstruction later
        self.error_messages = messages 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:48,代碼來源:__init__.py

示例8: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def __init__(self, verbose_name=None, name=None, primary_key=False,
            max_length=None, unique=False, blank=False, null=False,
            db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
            serialize=True, unique_for_date=None, unique_for_month=None,
            unique_for_year=None, choices=None, help_text='', db_column=None,
            db_tablespace=None, auto_created=False, validators=[],
            error_messages=None):
        self.name = name
        self.verbose_name = verbose_name
        self.primary_key = primary_key
        self.max_length, self._unique = max_length, unique
        self.blank, self.null = blank, null
        self.rel = rel
        self.default = default
        self.editable = editable
        self.serialize = serialize
        self.unique_for_date, self.unique_for_month = (unique_for_date,
                                                       unique_for_month)
        self.unique_for_year = unique_for_year
        self._choices = choices or []
        self.help_text = help_text
        self.db_column = db_column
        self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
        self.auto_created = auto_created

        # Set db_index to True if the field has a relationship and doesn't
        # explicitly set db_index.
        self.db_index = db_index

        # Adjust the appropriate creation counter, and save our local copy.
        if auto_created:
            self.creation_counter = Field.auto_creation_counter
            Field.auto_creation_counter -= 1
        else:
            self.creation_counter = Field.creation_counter
            Field.creation_counter += 1

        self.validators = self.default_validators + validators

        messages = {}
        for c in reversed(self.__class__.__mro__):
            messages.update(getattr(c, 'default_error_messages', {}))
        messages.update(error_messages or {})
        self.error_messages = messages 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:46,代碼來源:__init__.py

示例9: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEFAULT_INDEX_TABLESPACE [as 別名]
def __init__(self, verbose_name=None, name=None, primary_key=False,
            max_length=None, unique=False, blank=False, null=False,
            db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
            serialize=True, unique_for_date=None, unique_for_month=None,
            unique_for_year=None, choices=None, help_text='', db_column=None,
            db_tablespace=None, auto_created=False, validators=[],
            error_messages=None):
        self.name = name
        self.verbose_name = verbose_name  # May be set by set_attributes_from_name
        self._verbose_name = verbose_name  # Store original for deconstruction
        self.primary_key = primary_key
        self.max_length, self._unique = max_length, unique
        self.blank, self.null = blank, null
        self.remote_field = rel
        self.is_relation = self.remote_field is not None
        self.default = default
        self.editable = editable
        self.serialize = serialize
        self.unique_for_date = unique_for_date
        self.unique_for_month = unique_for_month
        self.unique_for_year = unique_for_year
        if isinstance(choices, collections.Iterator):
            choices = list(choices)
        self.choices = choices or []
        self.help_text = help_text
        self.db_index = db_index
        self.db_column = db_column
        self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
        self.auto_created = auto_created

        # Adjust the appropriate creation counter, and save our local copy.
        if auto_created:
            self.creation_counter = Field.auto_creation_counter
            Field.auto_creation_counter -= 1
        else:
            self.creation_counter = Field.creation_counter
            Field.creation_counter += 1

        self._validators = validators  # Store for deconstruction later

        messages = {}
        for c in reversed(self.__class__.__mro__):
            messages.update(getattr(c, 'default_error_messages', {}))
        messages.update(error_messages or {})
        self._error_messages = error_messages  # Store for deconstruction later
        self.error_messages = messages 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:48,代碼來源:__init__.py


注:本文中的django.conf.settings.DEFAULT_INDEX_TABLESPACE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。