-
-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.0] Add django.db.models.GeneratedField (#1944)
* Add django.db.models.GeneratedField * Fix all the known test failures for GeneratedField * Ignore cached_col cached_property issues * Removed default values from GeneratedField * Apply suggestions from code review --------- Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from typing import Any, Iterable, Literal | ||
|
||
from django.core.validators import _ValidatorCallable | ||
from django.db import models | ||
from django.db.backends.base.base import BaseDatabaseWrapper | ||
from django.db.models.expressions import Expression | ||
from django.db.models.fields import _ErrorMessagesMapping, _FieldChoices | ||
from django.db.models.sql import Query | ||
from django.utils.datastructures import DictWrapper | ||
from django.utils.functional import _StrOrPromise | ||
|
||
class GeneratedField(models.Field): | ||
generated: Literal[True] | ||
db_returning: Literal[True] | ||
_query: Query | None | ||
output_field: models.Field | None | ||
|
||
def __init__( | ||
self, | ||
*, | ||
expression: Expression, | ||
output_field: models.Field, | ||
db_persist: bool | None = ..., | ||
verbose_name: _StrOrPromise | None = ..., | ||
name: str | None = ..., | ||
primary_key: bool = ..., | ||
unique: bool = ..., | ||
blank: bool = ..., | ||
null: bool = ..., | ||
default: Any = ..., | ||
editable: bool = ..., | ||
auto_created: bool = ..., | ||
serialize: bool = ..., | ||
unique_for_date: str | None = ..., | ||
unique_for_month: str | None = ..., | ||
unique_for_year: str | None = ..., | ||
choices: _FieldChoices | None = ..., | ||
help_text: _StrOrPromise = ..., | ||
db_column: str | None = ..., | ||
db_comment: str | None = ..., | ||
db_tablespace: str | None = ..., | ||
validators: Iterable[_ValidatorCallable] = ..., | ||
error_messages: _ErrorMessagesMapping | None = ..., | ||
**kwargs: Any, | ||
) -> None: ... | ||
def generated_sql(self, connection: BaseDatabaseWrapper) -> tuple[str, Any]: ... | ||
def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters