Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5ab86809
Kaydet (Commit)
5ab86809
authored
Haz 01, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24892 -- Fixed quoting of SQL when renaming a field to AutoField in PostgreSQL
üst
0b5fb8e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
14 deletions
+41
-14
schema.py
django/db/backends/postgresql_psycopg2/schema.py
+8
-8
1.8.3.txt
docs/releases/1.8.3.txt
+3
-0
models.py
tests/schema/models.py
+8
-0
tests.py
tests/schema/tests.py
+22
-6
No files found.
django/db/backends/postgresql_psycopg2/schema.py
Dosyayı görüntüle @
5ab86809
...
@@ -52,31 +52,31 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
...
@@ -52,31 +52,31 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
[
[
(
(
self
.
sql_delete_sequence
%
{
self
.
sql_delete_sequence
%
{
"sequence"
:
se
quence_name
,
"sequence"
:
se
lf
.
quote_name
(
sequence_name
)
,
},
},
[],
[],
),
),
(
(
self
.
sql_create_sequence
%
{
self
.
sql_create_sequence
%
{
"sequence"
:
se
quence_name
,
"sequence"
:
se
lf
.
quote_name
(
sequence_name
)
,
},
},
[],
[],
),
),
(
(
self
.
sql_alter_column
%
{
self
.
sql_alter_column
%
{
"table"
:
table
,
"table"
:
self
.
quote_name
(
table
)
,
"changes"
:
self
.
sql_alter_column_default
%
{
"changes"
:
self
.
sql_alter_column_default
%
{
"column"
:
column
,
"column"
:
self
.
quote_name
(
column
)
,
"default"
:
"nextval('
%
s')"
%
se
quence_name
,
"default"
:
"nextval('
%
s')"
%
se
lf
.
quote_name
(
sequence_name
)
,
}
}
},
},
[],
[],
),
),
(
(
self
.
sql_set_sequence_max
%
{
self
.
sql_set_sequence_max
%
{
"table"
:
table
,
"table"
:
self
.
quote_name
(
table
)
,
"column"
:
column
,
"column"
:
self
.
quote_name
(
column
)
,
"sequence"
:
se
quence_name
,
"sequence"
:
se
lf
.
quote_name
(
sequence_name
)
,
},
},
[],
[],
),
),
...
...
docs/releases/1.8.3.txt
Dosyayı görüntüle @
5ab86809
...
@@ -31,3 +31,6 @@ Bugfixes
...
@@ -31,3 +31,6 @@ Bugfixes
* Fixed a crash when using a reverse one-to-one relation in
* Fixed a crash when using a reverse one-to-one relation in
``ModelAdmin.list_display`` (:ticket:`24851`).
``ModelAdmin.list_display`` (:ticket:`24851`).
* Fixed quoting of SQL when renaming a field to ``AutoField`` in PostgreSQL
(:ticket:`24892`).
tests/schema/models.py
Dosyayı görüntüle @
5ab86809
...
@@ -80,6 +80,14 @@ class BookWithSlug(models.Model):
...
@@ -80,6 +80,14 @@ class BookWithSlug(models.Model):
db_table
=
"schema_book"
db_table
=
"schema_book"
class
IntegerPK
(
models
.
Model
):
i
=
models
.
IntegerField
(
primary_key
=
True
)
class
Meta
:
apps
=
new_apps
db_table
=
"INTEGERPK"
# uppercase to ensure proper quoting
class
Note
(
models
.
Model
):
class
Note
(
models
.
Model
):
info
=
models
.
TextField
()
info
=
models
.
TextField
()
...
...
tests/schema/tests.py
Dosyayı görüntüle @
5ab86809
...
@@ -8,8 +8,8 @@ from django.db import (
...
@@ -8,8 +8,8 @@ from django.db import (
)
)
from
django.db.models
import
Model
from
django.db.models
import
Model
from
django.db.models.fields
import
(
from
django.db.models.fields
import
(
BigIntegerField
,
BinaryField
,
BooleanField
,
CharField
,
DateTime
Field
,
AutoField
,
BigIntegerField
,
BinaryField
,
BooleanField
,
Char
Field
,
IntegerField
,
PositiveIntegerField
,
SlugField
,
TextField
,
DateTimeField
,
IntegerField
,
PositiveIntegerField
,
SlugField
,
TextField
,
)
)
from
django.db.models.fields.related
import
(
from
django.db.models.fields.related
import
(
ForeignKey
,
ManyToManyField
,
OneToOneField
,
ForeignKey
,
ManyToManyField
,
OneToOneField
,
...
@@ -22,8 +22,8 @@ from .fields import (
...
@@ -22,8 +22,8 @@ from .fields import (
)
)
from
.models
import
(
from
.models
import
(
Author
,
AuthorWithDefaultHeight
,
AuthorWithEvenLongerName
,
Book
,
BookWeak
,
Author
,
AuthorWithDefaultHeight
,
AuthorWithEvenLongerName
,
Book
,
BookWeak
,
BookWithLongName
,
BookWithO2O
,
BookWithSlug
,
Note
,
NoteRename
,
Tag
,
BookWithLongName
,
BookWithO2O
,
BookWithSlug
,
IntegerPK
,
Note
,
NoteRename
,
TagIndexed
,
TagM2MTest
,
TagUniqueRename
,
Thing
,
UniqueTest
,
new_apps
,
Tag
,
Tag
Indexed
,
TagM2MTest
,
TagUniqueRename
,
Thing
,
UniqueTest
,
new_apps
,
)
)
...
@@ -40,8 +40,8 @@ class SchemaTests(TransactionTestCase):
...
@@ -40,8 +40,8 @@ class SchemaTests(TransactionTestCase):
models
=
[
models
=
[
Author
,
AuthorWithDefaultHeight
,
AuthorWithEvenLongerName
,
Book
,
Author
,
AuthorWithDefaultHeight
,
AuthorWithEvenLongerName
,
Book
,
BookWeak
,
BookWithLongName
,
BookWithO2O
,
BookWithSlug
,
Note
,
Tag
,
BookWeak
,
BookWithLongName
,
BookWithO2O
,
BookWithSlug
,
IntegerPK
,
Note
,
TagIndexed
,
TagM2MTest
,
TagUniqueRename
,
Thing
,
UniqueTest
,
Tag
,
Tag
Indexed
,
TagM2MTest
,
TagUniqueRename
,
Thing
,
UniqueTest
,
]
]
# Utility functions
# Utility functions
...
@@ -748,6 +748,22 @@ class SchemaTests(TransactionTestCase):
...
@@ -748,6 +748,22 @@ class SchemaTests(TransactionTestCase):
# field which drops the id sequence, at least on PostgreSQL.
# field which drops the id sequence, at least on PostgreSQL.
Author
.
objects
.
create
(
name
=
'Foo'
)
Author
.
objects
.
create
(
name
=
'Foo'
)
def
test_alter_int_pk_to_autofield_pk
(
self
):
"""
Should be able to rename an IntegerField(primary_key=True) to
AutoField(primary_key=True).
"""
with
connection
.
schema_editor
()
as
editor
:
editor
.
create_model
(
IntegerPK
)
old_field
=
IntegerPK
.
_meta
.
get_field
(
'i'
)
new_field
=
AutoField
(
primary_key
=
True
)
new_field
.
model
=
IntegerPK
new_field
.
set_attributes_from_name
(
'i'
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
IntegerPK
,
old_field
,
new_field
,
strict
=
True
)
def
test_rename
(
self
):
def
test_rename
(
self
):
"""
"""
Tests simple altering of fields
Tests simple altering of fields
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment