mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 18:05:58 +08:00
Add stub for OpClass (#617)
This commit is contained in:
@@ -2,7 +2,7 @@ from typing import Optional, Sequence, Union
|
|||||||
|
|
||||||
from django.db.models.query_utils import Q
|
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
|
from django.db.models.expressions import BaseExpression, Combinable
|
||||||
|
|
||||||
|
|
||||||
@@ -88,3 +88,10 @@ class SpGistIndex(PostgresIndex):
|
|||||||
condition: Optional[Q] = ...,
|
condition: Optional[Q] = ...,
|
||||||
include: Optional[Sequence[str]] = ...,
|
include: Optional[Sequence[str]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
|
class OpClass(Func):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
expression: Union[BaseExpression, Combinable, str],
|
||||||
|
name: str,
|
||||||
|
) -> None: ...
|
||||||
|
|||||||
@@ -16,3 +16,13 @@
|
|||||||
- index: GistIndex
|
- index: GistIndex
|
||||||
- index: HashIndex
|
- index: HashIndex
|
||||||
- index: SpGistIndex
|
- 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',
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user