summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/base.py
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2022-03-24 16:46:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-13 21:51:51 +0200
commit2eea361eff58dd98c409c5227064b901f41bd0d6 (patch)
treeb551c3b45c3d0f133d88ef346ec1657f937d2892 /django/db/backends/postgresql/base.py
parent62ffc9883afdc0a9f9674702661062508230d7bf (diff)
downloaddjango-2eea361eff58dd98c409c5227064b901f41bd0d6.tar.gz
Fixed #30511 -- Used identity columns instead of serials on PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r--django/db/backends/postgresql/base.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index 630da22964..2758c402ab 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -72,8 +72,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
# be interpolated against the values of Field.__dict__ before being output.
# If a column type is set to None, it won't be included in the output.
data_types = {
- "AutoField": "serial",
- "BigAutoField": "bigserial",
+ "AutoField": "integer",
+ "BigAutoField": "bigint",
"BinaryField": "bytea",
"BooleanField": "boolean",
"CharField": "varchar(%(max_length)s)",
@@ -94,7 +94,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
"PositiveIntegerField": "integer",
"PositiveSmallIntegerField": "smallint",
"SlugField": "varchar(%(max_length)s)",
- "SmallAutoField": "smallserial",
+ "SmallAutoField": "smallint",
"SmallIntegerField": "smallint",
"TextField": "text",
"TimeField": "time",
@@ -105,6 +105,11 @@ class DatabaseWrapper(BaseDatabaseWrapper):
"PositiveIntegerField": '"%(column)s" >= 0',
"PositiveSmallIntegerField": '"%(column)s" >= 0',
}
+ data_types_suffix = {
+ "AutoField": "GENERATED BY DEFAULT AS IDENTITY",
+ "BigAutoField": "GENERATED BY DEFAULT AS IDENTITY",
+ "SmallAutoField": "GENERATED BY DEFAULT AS IDENTITY",
+ }
operators = {
"exact": "= %s",
"iexact": "= UPPER(%s)",