Skip to content

Commit

Permalink
Create a nocase index for use with the LIKE queries
Browse files Browse the repository at this point in the history
  • Loading branch information
lieryan committed Jan 6, 2024
1 parent faa0b69 commit bd9262f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rope/contrib/autoimport/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ class Name(Model):
@classmethod
def create_table(cls, connection):
super().create_table(connection)
connection.execute("CREATE INDEX IF NOT EXISTS name ON names(name)")
connection.execute("CREATE INDEX IF NOT EXISTS module ON names(module)")
connection.execute("CREATE INDEX IF NOT EXISTS package ON names(package)")
# fmt: off
connection.execute("CREATE INDEX IF NOT EXISTS names_name ON names(name)")
connection.execute("CREATE INDEX IF NOT EXISTS names_module ON names(module)")
connection.execute("CREATE INDEX IF NOT EXISTS names_package ON names(package)")
connection.execute("CREATE INDEX IF NOT EXISTS names_name_nocase ON names(name COLLATE NOCASE)")
connection.execute("CREATE INDEX IF NOT EXISTS names_module_nocase ON names(module COLLATE NOCASE)")
connection.execute("CREATE INDEX IF NOT EXISTS names_package_nocase ON names(package COLLATE NOCASE)")
# fmt: on

search_submodule_like = objects.where('module LIKE ("%." || ?)')
search_module_like = objects.where("module LIKE (?)")
Expand Down

0 comments on commit bd9262f

Please sign in to comment.