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
48c4ea41
Kaydet (Commit)
48c4ea41
authored
Nis 22, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used migration framework in GIS test tearDown
üst
3c06b2f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
schema.py
django/contrib/gis/db/backends/postgis/schema.py
+8
-1
test_operations.py
django/contrib/gis/tests/gis_migrations/test_operations.py
+3
-10
No files found.
django/contrib/gis/db/backends/postgis/schema.py
Dosyayı görüntüle @
48c4ea41
...
...
@@ -10,6 +10,7 @@ class PostGISSchemaEditor(DatabaseSchemaEditor):
sql_drop_geometry_column
=
"SELECT DropGeometryColumn(
%(table)
s,
%(column)
s)"
sql_alter_geometry_column_not_null
=
"ALTER TABLE
%(table)
s ALTER COLUMN
%(column)
s SET NOT NULL"
sql_add_spatial_index
=
"CREATE INDEX
%(index)
s ON
%(table)
s USING
%(index_type)
s (
%(column)
s
%(ops)
s)"
sql_clear_geometry_columns
=
"DELETE FROM geometry_columns WHERE f_table_name =
%(table)
s"
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
PostGISSchemaEditor
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -46,7 +47,7 @@ class PostGISSchemaEditor(DatabaseSchemaEditor):
self
.
sql_alter_geometry_column_not_null
%
{
"table"
:
self
.
quote_name
(
model
.
_meta
.
db_table
),
"column"
:
self
.
quote_name
(
field
.
column
),
}
,
}
)
if
field
.
spatial_index
:
...
...
@@ -83,6 +84,12 @@ class PostGISSchemaEditor(DatabaseSchemaEditor):
self
.
execute
(
sql
)
self
.
geometry_sql
=
[]
def
delete_model
(
self
,
model
):
super
(
PostGISSchemaEditor
,
self
)
.
delete_model
(
model
)
self
.
execute
(
self
.
sql_clear_geometry_columns
%
{
"table"
:
self
.
geo_quote_name
(
model
.
_meta
.
db_table
),
})
def
add_field
(
self
,
model
,
field
):
super
(
PostGISSchemaEditor
,
self
)
.
add_field
(
model
,
field
)
# Create geometry columns
...
...
django/contrib/gis/tests/gis_migrations/test_operations.py
Dosyayı görüntüle @
48c4ea41
...
...
@@ -6,7 +6,6 @@ from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from
django.db
import
connection
,
migrations
,
models
from
django.db.migrations.migration
import
Migration
from
django.db.migrations.state
import
ProjectState
from
django.db.utils
import
DatabaseError
from
django.test
import
TransactionTestCase
if
HAS_SPATIAL_DB
:
...
...
@@ -24,15 +23,7 @@ class OperationTests(TransactionTestCase):
def
tearDown
(
self
):
# Delete table after testing
with
connection
.
cursor
()
as
cursor
:
try
:
cursor
.
execute
(
"DROP TABLE
%
s"
%
connection
.
ops
.
quote_name
(
"gis_neighborhood"
))
except
DatabaseError
:
pass
else
:
if
HAS_GEOMETRY_COLUMNS
:
cursor
.
execute
(
"DELETE FROM geometry_columns WHERE
%
s =
%%
s"
%
(
GeometryColumns
.
table_name_col
(),),
[
"gis_neighborhood"
])
self
.
apply_operations
(
'gis'
,
self
.
current_state
,
[
migrations
.
DeleteModel
(
"Neighborhood"
)])
super
(
OperationTests
,
self
)
.
tearDown
()
def
get_table_description
(
self
,
table
):
...
...
@@ -84,6 +75,7 @@ class OperationTests(TransactionTestCase):
GeometryColumns
.
objects
.
filter
(
**
{
GeometryColumns
.
table_name_col
():
"gis_neighborhood"
})
.
count
(),
2
)
self
.
current_state
=
new_state
def
test_remove_gis_field
(
self
):
"""
...
...
@@ -103,3 +95,4 @@ class OperationTests(TransactionTestCase):
GeometryColumns
.
objects
.
filter
(
**
{
GeometryColumns
.
table_name_col
():
"gis_neighborhood"
})
.
count
(),
0
)
self
.
current_state
=
new_state
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