plain.models 0.38.0__tar.gz → 0.39.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plain_models-0.38.0 → plain_models-0.39.1}/PKG-INFO +32 -1
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/CHANGELOG.md +31 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/README.md +31 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/__init__.py +2 -2
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/creation.py +1 -1
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/operations.py +1 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/schema.py +4 -8
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/base.py +1 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/introspection.py +2 -6
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/operations.py +2 -4
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/base.py +2 -6
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/introspection.py +2 -6
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/operations.py +1 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/schema.py +2 -10
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/base.py +2 -6
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/introspection.py +2 -8
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/base.py +46 -74
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/constraints.py +3 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/deletion.py +9 -9
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/__init__.py +30 -104
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/related.py +90 -343
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/related_descriptors.py +14 -14
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/related_lookups.py +2 -2
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/reverse_related.py +6 -14
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/forms.py +14 -76
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/lookups.py +2 -2
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/autodetector.py +2 -25
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/operations/fields.py +0 -6
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/state.py +2 -26
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/utils.py +4 -14
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/options.py +4 -12
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/query.py +46 -54
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/query_utils.py +3 -5
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/compiler.py +16 -18
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/query.py +12 -11
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/subqueries.py +10 -10
- {plain_models-0.38.0 → plain_models-0.39.1}/pyproject.toml +1 -1
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/examples/migrations/0001_initial.py +1 -1
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/examples/migrations/0003_deleteparent_childsetnull_childsetdefault_and_more.py +7 -7
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/examples/models.py +3 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/test_delete_behaviors.py +3 -3
- {plain_models-0.38.0 → plain_models-0.39.1}/.gitignore +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/LICENSE +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/README.md +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/aggregates.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/base.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/client.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/features.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/introspection.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/base/validation.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/ddl_references.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/client.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/compiler.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/creation.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/features.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/schema.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/mysql/validation.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/client.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/creation.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/features.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/_functions.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/client.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/creation.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/features.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/operations.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/sqlite3/schema.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/utils.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backups/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backups/cli.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backups/clients.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backups/core.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/cli.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/config.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/connections.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/constants.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/database_url.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/db.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/default_settings.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/entrypoints.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/enums.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/exceptions.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/expressions.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/json.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/fields/mixins.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/comparison.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/datetime.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/math.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/mixins.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/text.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/functions/window.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/indexes.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/manager.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/exceptions.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/executor.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/graph.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/loader.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/migration.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/operations/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/operations/base.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/operations/models.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/operations/special.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/optimizer.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/questioner.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/recorder.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/serializer.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/migrations/writer.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/otel.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/preflight.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/registry.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/constants.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/datastructures.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/sql/where.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/test/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/test/pytest.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/test/utils.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/transaction.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/plain/models/utils.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/examples/migrations/0002_test_field_removed.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/examples/migrations/__init__.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/settings.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/app/urls.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/test_database_url.py +0 -0
- {plain_models-0.38.0 → plain_models-0.39.1}/tests/test_models.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: plain.models
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.39.1
|
4
4
|
Summary: Database models for Plain.
|
5
5
|
Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
|
6
6
|
License-File: LICENSE
|
@@ -30,6 +30,9 @@ class User(models.Model):
|
|
30
30
|
return self.email
|
31
31
|
```
|
32
32
|
|
33
|
+
Every model automatically includes an `id` field which serves as the primary
|
34
|
+
key. The name `id` is reserved and can't be used for other fields.
|
35
|
+
|
33
36
|
Create, update, and delete instances of your models:
|
34
37
|
|
35
38
|
```python
|
@@ -114,3 +117,31 @@ TODO
|
|
114
117
|
## Forms
|
115
118
|
|
116
119
|
TODO
|
120
|
+
|
121
|
+
## Sharing fields across models
|
122
|
+
|
123
|
+
To share common fields across multiple models, use Python classes as mixins. The final, registered model must inherit directly from `models.Model` and the mixins should not.
|
124
|
+
|
125
|
+
```python
|
126
|
+
from plain import models
|
127
|
+
|
128
|
+
|
129
|
+
# Regular Python class for shared fields
|
130
|
+
class TimestampedMixin:
|
131
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
132
|
+
updated_at = models.DateTimeField(auto_now=True)
|
133
|
+
|
134
|
+
|
135
|
+
# Models inherit from the mixin AND models.Model
|
136
|
+
@models.register_model
|
137
|
+
class User(TimestampedMixin, models.Model):
|
138
|
+
email = models.EmailField()
|
139
|
+
password = PasswordField()
|
140
|
+
is_admin = models.BooleanField(default=False)
|
141
|
+
|
142
|
+
|
143
|
+
@models.register_model
|
144
|
+
class Note(TimestampedMixin, models.Model):
|
145
|
+
content = models.TextField(max_length=1024)
|
146
|
+
liked = models.BooleanField(default=False)
|
147
|
+
```
|
@@ -1,5 +1,36 @@
|
|
1
1
|
# plain-models changelog
|
2
2
|
|
3
|
+
## [0.39.1](https://github.com/dropseed/plain/releases/plain-models@0.39.1) (2025-07-22)
|
4
|
+
|
5
|
+
### What's changed
|
6
|
+
|
7
|
+
- Added documentation for sharing fields across models using Python class mixins ([cad3af01d2](https://github.com/dropseed/plain/commit/cad3af01d2))
|
8
|
+
- Added note about `PrimaryKeyField()` replacement requirement for migrations ([70ea931660](https://github.com/dropseed/plain/commit/70ea931660))
|
9
|
+
|
10
|
+
### Upgrade instructions
|
11
|
+
|
12
|
+
- No changes required
|
13
|
+
|
14
|
+
## [0.39.0](https://github.com/dropseed/plain/releases/plain-models@0.39.0) (2025-07-22)
|
15
|
+
|
16
|
+
### What's changed
|
17
|
+
|
18
|
+
- Models now use a single automatic `id` field as the primary key, replacing the previous `pk` alias and automatic field system ([4b8fa6a](https://github.com/dropseed/plain/commit/4b8fa6a))
|
19
|
+
- Removed the `to_field` option for ForeignKey - foreign keys now always reference the primary key of the related model ([7fc3c88](https://github.com/dropseed/plain/commit/7fc3c88))
|
20
|
+
- Removed the internal `from_fields` and `to_fields` system used for multi-column foreign keys ([0e9eda3](https://github.com/dropseed/plain/commit/0e9eda3))
|
21
|
+
- Removed the `parent_link` parameter on ForeignKey and ForeignObject ([6658647](https://github.com/dropseed/plain/commit/6658647))
|
22
|
+
- Removed `InlineForeignKeyField` from forms ([ede6265](https://github.com/dropseed/plain/commit/ede6265))
|
23
|
+
- Merged ForeignObject functionality into ForeignKey, simplifying the foreign key implementation ([e6d9aaa](https://github.com/dropseed/plain/commit/e6d9aaa))
|
24
|
+
- Cleaned up unused code in ForeignKey and fixed ForeignObjectRel imports ([b656ee6](https://github.com/dropseed/plain/commit/b656ee6))
|
25
|
+
|
26
|
+
### Upgrade instructions
|
27
|
+
|
28
|
+
- Replace any direct references to `pk` with `id` in your models and queries (e.g., `user.pk` becomes `user.id`)
|
29
|
+
- Remove any `to_field` arguments from ForeignKey definitions - they are no longer supported
|
30
|
+
- Remove any `parent_link=True` arguments from ForeignKey definitions - they are no longer supported
|
31
|
+
- Replace any usage of `InlineForeignKeyField` in forms with standard form fields
|
32
|
+
- `models.BigAutoField(auto_created=True, primary_key=True)` need to be replaced with `models.PrimaryKeyField()` in migrations
|
33
|
+
|
3
34
|
## [0.38.0](https://github.com/dropseed/plain/releases/plain-models@0.38.0) (2025-07-21)
|
4
35
|
|
5
36
|
### What's changed
|
@@ -19,6 +19,9 @@ class User(models.Model):
|
|
19
19
|
return self.email
|
20
20
|
```
|
21
21
|
|
22
|
+
Every model automatically includes an `id` field which serves as the primary
|
23
|
+
key. The name `id` is reserved and can't be used for other fields.
|
24
|
+
|
22
25
|
Create, update, and delete instances of your models:
|
23
26
|
|
24
27
|
```python
|
@@ -103,3 +106,31 @@ TODO
|
|
103
106
|
## Forms
|
104
107
|
|
105
108
|
TODO
|
109
|
+
|
110
|
+
## Sharing fields across models
|
111
|
+
|
112
|
+
To share common fields across multiple models, use Python classes as mixins. The final, registered model must inherit directly from `models.Model` and the mixins should not.
|
113
|
+
|
114
|
+
```python
|
115
|
+
from plain import models
|
116
|
+
|
117
|
+
|
118
|
+
# Regular Python class for shared fields
|
119
|
+
class TimestampedMixin:
|
120
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
121
|
+
updated_at = models.DateTimeField(auto_now=True)
|
122
|
+
|
123
|
+
|
124
|
+
# Models inherit from the mixin AND models.Model
|
125
|
+
@models.register_model
|
126
|
+
class User(TimestampedMixin, models.Model):
|
127
|
+
email = models.EmailField()
|
128
|
+
password = PasswordField()
|
129
|
+
is_admin = models.BooleanField(default=False)
|
130
|
+
|
131
|
+
|
132
|
+
@models.register_model
|
133
|
+
class Note(TimestampedMixin, models.Model):
|
134
|
+
content = models.TextField(max_length=1024)
|
135
|
+
liked = models.BooleanField(default=False)
|
136
|
+
```
|
@@ -68,8 +68,9 @@ from .registry import models_registry, register_model
|
|
68
68
|
from .base import DEFERRED, Model # isort:skip
|
69
69
|
from .fields.related import ( # isort:skip
|
70
70
|
ForeignKey,
|
71
|
-
ForeignObject,
|
72
71
|
ManyToManyField,
|
72
|
+
)
|
73
|
+
from .fields.reverse_related import ( # isort:skip
|
73
74
|
ForeignObjectRel,
|
74
75
|
ManyToOneRel,
|
75
76
|
ManyToManyRel,
|
@@ -116,7 +117,6 @@ __all__ += [
|
|
116
117
|
"Model",
|
117
118
|
"FilteredRelation",
|
118
119
|
"ForeignKey",
|
119
|
-
"ForeignObject",
|
120
120
|
"ManyToManyField",
|
121
121
|
"ForeignObjectRel",
|
122
122
|
"ManyToOneRel",
|
@@ -96,7 +96,7 @@ class BaseDatabaseCreation:
|
|
96
96
|
# ) and router.allow_migrate_model(self.connection.alias, model):
|
97
97
|
# queryset = model._base_manager.using(
|
98
98
|
# self.connection.alias,
|
99
|
-
# ).order_by(
|
99
|
+
# ).order_by("id")
|
100
100
|
# yield from queryset.iterator()
|
101
101
|
|
102
102
|
# # Serialize to a string
|
@@ -28,9 +28,7 @@ class BaseDatabaseOperations:
|
|
28
28
|
"PositiveBigIntegerField": (0, 9223372036854775807),
|
29
29
|
"PositiveSmallIntegerField": (0, 32767),
|
30
30
|
"PositiveIntegerField": (0, 2147483647),
|
31
|
-
"
|
32
|
-
"AutoField": (-2147483648, 2147483647),
|
33
|
-
"BigAutoField": (-9223372036854775808, 9223372036854775807),
|
31
|
+
"PrimaryKeyField": (-9223372036854775808, 9223372036854775807),
|
34
32
|
}
|
35
33
|
set_operators = {
|
36
34
|
"union": "UNION",
|
@@ -29,11 +29,11 @@ def _is_relevant_relation(relation, altered_field):
|
|
29
29
|
if field.many_to_many:
|
30
30
|
# M2M reverse field
|
31
31
|
return False
|
32
|
-
if altered_field.primary_key
|
32
|
+
if altered_field.primary_key:
|
33
33
|
# Foreign key constraint on the primary key, which is being altered.
|
34
34
|
return True
|
35
|
-
#
|
36
|
-
return altered_field.name
|
35
|
+
# ForeignKey always targets 'id'
|
36
|
+
return altered_field.name == "id"
|
37
37
|
|
38
38
|
|
39
39
|
def _all_related_fields(model):
|
@@ -239,11 +239,7 @@ class BaseDatabaseSchemaEditor:
|
|
239
239
|
column_sqls.append(f"{self.quote_name(field.column)} {definition}")
|
240
240
|
# Autoincrement SQL (for backends with post table definition
|
241
241
|
# variant).
|
242
|
-
if field.get_internal_type() in (
|
243
|
-
"AutoField",
|
244
|
-
"BigAutoField",
|
245
|
-
"SmallAutoField",
|
246
|
-
):
|
242
|
+
if field.get_internal_type() in ("PrimaryKeyField",):
|
247
243
|
autoinc_sql = self.connection.ops.autoinc_sql(
|
248
244
|
model._meta.db_table, field.column
|
249
245
|
)
|
@@ -91,8 +91,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
91
91
|
# be interpolated against the values of Field.__dict__ before being output.
|
92
92
|
# If a column type is set to None, it won't be included in the output.
|
93
93
|
data_types = {
|
94
|
-
"
|
95
|
-
"BigAutoField": "bigint AUTO_INCREMENT",
|
94
|
+
"PrimaryKeyField": "bigint AUTO_INCREMENT",
|
96
95
|
"BinaryField": "longblob",
|
97
96
|
"BooleanField": "bool",
|
98
97
|
"CharField": "varchar(%(max_length)s)",
|
@@ -109,7 +108,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
109
108
|
"PositiveBigIntegerField": "bigint UNSIGNED",
|
110
109
|
"PositiveIntegerField": "integer UNSIGNED",
|
111
110
|
"PositiveSmallIntegerField": "smallint UNSIGNED",
|
112
|
-
"SmallAutoField": "smallint AUTO_INCREMENT",
|
113
111
|
"SmallIntegerField": "smallint",
|
114
112
|
"TextField": "longtext",
|
115
113
|
"TimeField": "time(6)",
|
@@ -49,12 +49,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|
49
49
|
def get_field_type(self, data_type, description):
|
50
50
|
field_type = super().get_field_type(data_type, description)
|
51
51
|
if "auto_increment" in description.extra:
|
52
|
-
if field_type == "
|
53
|
-
return "
|
54
|
-
elif field_type == "BigIntegerField":
|
55
|
-
return "BigAutoField"
|
56
|
-
elif field_type == "SmallIntegerField":
|
57
|
-
return "SmallAutoField"
|
52
|
+
if field_type == "BigIntegerField":
|
53
|
+
return "PrimaryKeyField"
|
58
54
|
if description.is_unsigned:
|
59
55
|
if field_type == "BigIntegerField":
|
60
56
|
return "PositiveBigIntegerField"
|
@@ -21,9 +21,7 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|
21
21
|
"PositiveBigIntegerField": (0, 18446744073709551615),
|
22
22
|
}
|
23
23
|
cast_data_types = {
|
24
|
-
"
|
25
|
-
"BigAutoField": "signed integer",
|
26
|
-
"SmallAutoField": "signed integer",
|
24
|
+
"PrimaryKeyField": "signed integer",
|
27
25
|
"CharField": "char(%(max_length)s)",
|
28
26
|
"DecimalField": "decimal(%(max_digits)s, %(decimal_places)s)",
|
29
27
|
"TextField": "char",
|
@@ -201,7 +199,7 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|
201
199
|
# NO_AUTO_VALUE_ON_ZERO SQL mode.
|
202
200
|
if value == 0 and not self.connection.features.allows_auto_pk_0:
|
203
201
|
raise ValueError(
|
204
|
-
"The database backend does not accept 0 as a value for
|
202
|
+
"The database backend does not accept 0 as a value for PrimaryKeyField."
|
205
203
|
)
|
206
204
|
return value
|
207
205
|
|
@@ -89,8 +89,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
89
89
|
# be interpolated against the values of Field.__dict__ before being output.
|
90
90
|
# If a column type is set to None, it won't be included in the output.
|
91
91
|
data_types = {
|
92
|
-
"
|
93
|
-
"BigAutoField": "bigint",
|
92
|
+
"PrimaryKeyField": "bigint",
|
94
93
|
"BinaryField": "bytea",
|
95
94
|
"BooleanField": "boolean",
|
96
95
|
"CharField": _get_varchar_column,
|
@@ -107,7 +106,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
107
106
|
"PositiveBigIntegerField": "bigint",
|
108
107
|
"PositiveIntegerField": "integer",
|
109
108
|
"PositiveSmallIntegerField": "smallint",
|
110
|
-
"SmallAutoField": "smallint",
|
111
109
|
"SmallIntegerField": "smallint",
|
112
110
|
"TextField": "text",
|
113
111
|
"TimeField": "time",
|
@@ -119,9 +117,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
119
117
|
"PositiveSmallIntegerField": '"%(column)s" >= 0',
|
120
118
|
}
|
121
119
|
data_types_suffix = {
|
122
|
-
"
|
123
|
-
"BigAutoField": "GENERATED BY DEFAULT AS IDENTITY",
|
124
|
-
"SmallAutoField": "GENERATED BY DEFAULT AS IDENTITY",
|
120
|
+
"PrimaryKeyField": "GENERATED BY DEFAULT AS IDENTITY",
|
125
121
|
}
|
126
122
|
operators = {
|
127
123
|
"exact": "= %s",
|
{plain_models-0.38.0 → plain_models-0.39.1}/plain/models/backends/postgresql/introspection.py
RENAMED
@@ -44,12 +44,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|
44
44
|
# Required for pre-Plain 4.1 serial columns.
|
45
45
|
description.default and "nextval" in description.default
|
46
46
|
):
|
47
|
-
if field_type == "
|
48
|
-
return "
|
49
|
-
elif field_type == "BigIntegerField":
|
50
|
-
return "BigAutoField"
|
51
|
-
elif field_type == "SmallIntegerField":
|
52
|
-
return "SmallAutoField"
|
47
|
+
if field_type == "BigIntegerField":
|
48
|
+
return "PrimaryKeyField"
|
53
49
|
return field_type
|
54
50
|
|
55
51
|
def get_table_list(self, cursor):
|
@@ -166,11 +166,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|
166
166
|
old_internal_type = old_field.get_internal_type()
|
167
167
|
# Make ALTER TYPE with IDENTITY make sense.
|
168
168
|
table = strip_quotes(model._meta.db_table)
|
169
|
-
auto_field_types = {
|
170
|
-
"AutoField",
|
171
|
-
"BigAutoField",
|
172
|
-
"SmallAutoField",
|
173
|
-
}
|
169
|
+
auto_field_types = {"PrimaryKeyField"}
|
174
170
|
old_is_auto = old_internal_type in auto_field_types
|
175
171
|
new_is_auto = new_internal_type in auto_field_types
|
176
172
|
if new_is_auto and not old_is_auto:
|
@@ -229,11 +225,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|
229
225
|
model, old_field, new_field, new_type, old_collation, new_collation
|
230
226
|
)
|
231
227
|
column = strip_quotes(new_field.column)
|
232
|
-
db_types = {
|
233
|
-
"AutoField": "integer",
|
234
|
-
"BigAutoField": "bigint",
|
235
|
-
"SmallAutoField": "smallint",
|
236
|
-
}
|
228
|
+
db_types = {"PrimaryKeyField": "bigint"}
|
237
229
|
# Alter the sequence type if exists (Plain 4.1+ identity columns
|
238
230
|
# don't have it).
|
239
231
|
other_actions = []
|
@@ -57,8 +57,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
57
57
|
# thing" given more verbose field definitions, so leave them as is so that
|
58
58
|
# schema inspection is more useful.
|
59
59
|
data_types = {
|
60
|
-
"
|
61
|
-
"BigAutoField": "integer",
|
60
|
+
"PrimaryKeyField": "integer",
|
62
61
|
"BinaryField": "BLOB",
|
63
62
|
"BooleanField": "bool",
|
64
63
|
"CharField": "varchar(%(max_length)s)",
|
@@ -75,7 +74,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
75
74
|
"PositiveBigIntegerField": "bigint unsigned",
|
76
75
|
"PositiveIntegerField": "integer unsigned",
|
77
76
|
"PositiveSmallIntegerField": "smallint unsigned",
|
78
|
-
"SmallAutoField": "integer",
|
79
77
|
"SmallIntegerField": "smallint",
|
80
78
|
"TextField": "text",
|
81
79
|
"TimeField": "time",
|
@@ -88,9 +86,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|
88
86
|
"PositiveSmallIntegerField": '"%(column)s" >= 0',
|
89
87
|
}
|
90
88
|
data_types_suffix = {
|
91
|
-
"
|
92
|
-
"BigAutoField": "AUTOINCREMENT",
|
93
|
-
"SmallAutoField": "AUTOINCREMENT",
|
89
|
+
"PrimaryKeyField": "AUTOINCREMENT",
|
94
90
|
}
|
95
91
|
# SQLite requires LIKE statements to include an ESCAPE clause if the value
|
96
92
|
# being escaped has a percent or underscore in it.
|
@@ -63,14 +63,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
|
63
63
|
|
64
64
|
def get_field_type(self, data_type, description):
|
65
65
|
field_type = super().get_field_type(data_type, description)
|
66
|
-
if description.pk and field_type
|
67
|
-
"
|
68
|
-
"IntegerField",
|
69
|
-
"SmallIntegerField",
|
70
|
-
}:
|
71
|
-
# No support for BigAutoField or SmallAutoField as SQLite treats
|
72
|
-
# all integer primary keys as signed 64-bit integers.
|
73
|
-
return "AutoField"
|
66
|
+
if description.pk and field_type == "BigIntegerField":
|
67
|
+
return "PrimaryKeyField"
|
74
68
|
if description.has_json_constraint:
|
75
69
|
return "JSONField"
|
76
70
|
return field_type
|