Add stub for OpClass (#617)

This commit is contained in:
Anton Agestam
2021-05-19 10:09:31 +02:00
committed by GitHub
parent 248f1cccee
commit 6dd8384381
2 changed files with 18 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ from typing import Optional, Sequence, Union
from django.db.models.query_utils import Q
from django.db.models import Index
from django.db.models import Index, Func
from django.db.models.expressions import BaseExpression, Combinable
@@ -88,3 +88,10 @@ class SpGistIndex(PostgresIndex):
condition: Optional[Q] = ...,
include: Optional[Sequence[str]] = ...,
) -> None: ...
class OpClass(Func):
def __init__(
self,
expression: Union[BaseExpression, Combinable, str],
name: str,
) -> None: ...

View File

@@ -16,3 +16,13 @@
- index: GistIndex
- index: HashIndex
- index: SpGistIndex
- case: can_instantiate_opclass
main: |
from django.db.models import Index
from django.db.models.functions import Lower
from django.contrib.postgres.indexes import OpClass
Index(
OpClass(Lower('username'), name='varchar_pattern_ops'),
name='lower_username_idx',
)