class Meta: db_table = "annotations" indexes = [ GinIndex( fields=['user', 'data', 'updated', 'sessionId'], name='annotation_gin' ) ]
class Meta(BaseCollection.Meta): """Entity Meta options.""" permissions = ( ("view_entity", "Can view entity"), ("edit_entity", "Can edit entity"), ("share_entity", "Can share entity"), ("owner_entity", "Is owner of the entity"), ) indexes = [ models.Index(name="idx_entity_name", fields=["name"]), GinIndex( name="idx_entity_name_trgm", fields=["name"], opclasses=["gin_trgm_ops"] ), models.Index(name="idx_entity_slug", fields=["slug"]), GinIndex(name="idx_entity_tags", fields=["tags"]), GinIndex(name="idx_entity_search", fields=["search"]), ]
class Meta: indexes = [GinIndex(fields=[ 'description_vector', 'title_vector', ])] # class Keys(models.Model): # key = models.CharField(null=True, blank=True, max_length=200) # value = models.BooleanField(null=True, blank=True)
class Meta: ordering = ("pk", ) indexes = [ GinIndex( name="address_search_gin", # `opclasses` and `fields` should be the same length fields=["first_name", "last_name", "city", "country"], opclasses=["gin_trgm_ops"] * 4, ), ]
class Meta: indexes = [ models.Index(fields=['slug'], name='project_slug_idx'), models.Index(fields=['status'], name='project_status_idx'), models.Index(fields=['level'], name='project_level_idx'), models.Index(fields=['is_premium'], name='project_is_premium_idx'), GinIndex(fields=['search_vector'], name='project_search_vector_idx'), ] ordering = ['-pk']
class Meta: unique_together = (('name', 'repo'), ) indexes = ( GinIndex(name="package_name", fields=["name"], opclasses=["gin_trgm_ops"]), SearchVectorIndex(name="package_description_search", fields=["description"], config="english"), )
class Meta: ordering = ("pk", ) permissions = (( PaymentPermissions.HANDLE_PAYMENTS.codename, "Handle payments", ), ) indexes = [ # Orders filtering by status index GinIndex(fields=["order_id", "is_active", "charge_status"]), ]
class Meta: indexes = [ *ModelWithMetadata.Meta.indexes, GinIndex( name="category_search_name_slug_gin", # `opclasses` and `fields` should be the same length fields=["name", "slug", "description_plaintext"], opclasses=["gin_trgm_ops"] * 3, ), ]
class Meta: db_table = 'persons_categories' verbose_name_plural = 'Categories' ordering = ('type', 'display_order') indexes = [ GinIndex( fields=['infos'], name='category_infos_gin', ), ]
class Meta: ordering = ("name", ) indexes = [ GinIndex( name="gift_card_tag_search_gin", # `opclasses` and `fields` should be the same length fields=["name"], opclasses=["gin_trgm_ops"], ), ]
class Meta: indexes = [ # A GIN index over the data field to allow efficient indexing of the composite type. # https://www.postgresql.org/docs/current/static/gin-intro.html GinIndex(fields=['data']), # A simple index over the type which is a common field used for filtering the initial # set of resources models.Index(fields=['type']), ]
class Meta: ordering = ['created'] indexes = [ BrinIndex(fields=['id']), GinIndex(fields=['title']), ] db_table = 'snippets' app_label = 'snippets' verbose_name = _("Snippet") verbose_name_plural = _("Snippets")
class Meta: ordering = ("-pk", ) permissions = ((OrderPermissions.MANAGE_ORDERS.codename, "Manage orders."), ) indexes = [ *ModelWithMetadata.Meta.indexes, GinIndex( name="order_search_gin", # `opclasses` and `fields` should be the same length fields=["search_document"], opclasses=["gin_trgm_ops"], ), GinIndex( name="order_email_search_gin", # `opclasses` and `fields` should be the same length fields=["user_email"], opclasses=["gin_trgm_ops"], ), ]
class Meta: indexes = [ models.Index(fields=["user", "-modified_date", "deleted"]), models.Index(fields=["-modified_date", "full_text", "deleted"]), models.Index(fields=["-modified_date"]), models.Index(fields=["user", "full_text", "-modified_date"]), models.Index(fields=["user", "-modified_date", "hibernated"]), models.Index(fields=["user", "-tweet_id"]), GinIndex(fields=["search_vector"]), ]
class Meta(ModelWithMetadata.Meta): ordering = ("slug", ) permissions = (( PageTypePermissions.MANAGE_PAGE_TYPES_AND_ATTRIBUTES.codename, "Manage page types and attributes.", ), ) indexes = [ *ModelWithMetadata.Meta.indexes, GinIndex(fields=["name", "slug"]) ]
class Meta: indexes = [ models.Index( fields=['version'], name='version_idx', ), GinIndex( fields=['metadata'], name='metadata_gin', ), ]
def test_gin_parameters(self): index_name = 'integer_array_gin_params' index = GinIndex(fields=['field'], name=index_name, fastupdate=True, gin_pending_list_limit=64) with connection.schema_editor() as editor: editor.add_index(IntegerArrayModel, index) constraints = self.get_constraints(IntegerArrayModel._meta.db_table) self.assertEqual(constraints[index_name]['type'], 'gin') self.assertEqual(constraints[index_name]['options'], ['gin_pending_list_limit=64', 'fastupdate=on']) with connection.schema_editor() as editor: editor.remove_index(IntegerArrayModel, index) self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
def test_gin_fastupdate(self): index_name = 'integer_array_gin_fastupdate' index = GinIndex(fields=['field'], name=index_name, fastupdate=False) with connection.schema_editor() as editor: editor.add_index(IntegerArrayModel, index) constraints = self.get_constraints(IntegerArrayModel._meta.db_table) self.assertEqual(constraints[index_name]['type'], 'gin') self.assertEqual(constraints[index_name]['options'], ['fastupdate=off']) with connection.schema_editor() as editor: editor.remove_index(IntegerArrayModel, index) self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
class Meta: ordering = ("sort_order", "pk") unique_together = ("slug", "attribute") indexes = [ GinIndex( name="attribute_search_gin", # `opclasses` and `fields` should be the same length fields=["name", "slug"], opclasses=["gin_trgm_ops"] * 2, ) ]
class Meta: indexes = [ models.Index( fields=["version"], name="version_idx", ), GinIndex( fields=["metadata"], name="metadata_gin", ), ]
def test_gin_parameters_exception(self): index_name = 'gin_options_exception' index = GinIndex(fields=['field'], name=index_name, gin_pending_list_limit=64) msg = 'GIN option gin_pending_list_limit requires PostgreSQL 9.5+.' with self.assertRaisesMessage(NotSupportedError, msg): with connection.schema_editor() as editor: editor.add_index(IntegerArrayModel, index) self.assertNotIn( index_name, self.get_constraints(IntegerArrayModel._meta.db_table))
def test_partial_gin_index(self): with register_lookup(CharField, Length): index_name = 'char_field_gin_partial_idx' index = GinIndex(fields=['field'], name=index_name, condition=Q(field__length=40)) with connection.schema_editor() as editor: editor.add_index(CharFieldModel, index) constraints = self.get_constraints(CharFieldModel._meta.db_table) self.assertEqual(constraints[index_name]['type'], 'gin') with connection.schema_editor() as editor: editor.remove_index(CharFieldModel, index) self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table))
class Meta(BaseModel.Meta): """Data Meta options.""" permissions = ( ("view_data", "Can view data"), ("edit_data", "Can edit data"), ("share_data", "Can share data"), ("owner_data", "Is owner of the data"), ) indexes = [ models.Index(name="idx_data_name", fields=["name"]), GinIndex(name="idx_data_name_trgm", fields=["name"], opclasses=["gin_trgm_ops"]), models.Index(name="idx_data_slug", fields=["slug"]), models.Index(name="idx_data_status", fields=["status"]), GinIndex(name="idx_data_tags", fields=["tags"]), GinIndex(name="idx_data_search", fields=["search"]), ]
class Meta: verbose_name = "Ville française" verbose_name_plural = "Villes françaises" indexes = [ # https://docs.djangoproject.com/en/dev/ref/contrib/postgres/search/#trigram-similarity # https://docs.djangoproject.com/en/dev/ref/contrib/postgres/indexes/#ginindex # https://www.postgresql.org/docs/11/pgtrgm.html#id-1.11.7.40.7 GinIndex(fields=["name"], name="cities_city_name_gin_trgm", opclasses=["gin_trgm_ops"]) ]
class Meta(ModelWithMetadata.Meta): ordering = ("slug",) indexes = [ *ModelWithMetadata.Meta.indexes, GinIndex( name="collection_search_gin", # `opclasses` and `fields` should be the same length fields=["name", "slug"], opclasses=["gin_trgm_ops"] * 2, ), ]
class Meta: ordering = ("email", ) permissions = ( (AccountPermissions.MANAGE_USERS.codename, "Manage customers."), (AccountPermissions.MANAGE_STAFF.codename, "Manage staff."), ) indexes = [ *ModelWithMetadata.Meta.indexes, # Orders searching index GinIndex(fields=["email", "first_name", "last_name"]), ]
class Meta: db_table = "partitioned_tables" unique_together = ("schema_name", "table_name") indexes = [ models.Index(name="partable_table", fields=["schema_name", "table_name"]), models.Index(name="partable_partition_type", fields=["partition_type"]), GinIndex(name="partable_partition_parameters", fields=["partition_parameters"]), ]
class Meta: unique_together = ( ("customer", "remote_id"), ("customer", "internal_id"), ) indexes = [ GinIndex( fields=["filterable_attributes"], name="appcompany_fa_gin", ), ]
class Migration(migrations.Migration): dependencies = [ ("posthog", "0160_organization_domain_whitelist"), ] operations = [ TrigramExtension(), migrations.AddIndex( model_name="eventdefinition", index=GinIndex(fields=["name"], name="index_event_definition_name", opclasses=["gin_trgm_ops"]), ), migrations.AddIndex( model_name="propertydefinition", index=GinIndex(fields=["name"], name="index_property_definition_name", opclasses=["gin_trgm_ops"]), ), ]
class Meta(BaseCollection.Meta): """Collection Meta options.""" permissions = ( ("view_collection", "Can view collection"), ("edit_collection", "Can edit collection"), ("share_collection", "Can share collection"), ("owner_collection", "Is owner of the collection"), ) indexes = [ models.Index(name="idx_collection_name", fields=["name"]), GinIndex( name="idx_collection_name_trgm", fields=["name"], opclasses=["gin_trgm_ops"], ), models.Index(name="idx_collection_slug", fields=["slug"]), GinIndex(name="idx_collection_tags", fields=["tags"]), GinIndex(name="idx_collection_search", fields=["search"]), ]