Opened 10 years ago
Closed 5 years ago
#5401 closed defect (wontfix)
MSSQLSpatial driver incorrectly identifies tables with the same name but different schema as the same table
Reported by: | plectrum20 | Owned by: | tamas |
---|---|---|---|
Priority: | normal | Milestone: | closed_because_of_github_migration |
Component: | OGR_SF | Version: | 1.10.1 |
Severity: | normal | Keywords: | |
Cc: |
Description
The MSSQLSpatial driver seems ignores the schema when checking to see if a table exists and when dropping what it thinks is an existing table.
For example, I'm trying to import a layer "Countries" into schema "schema1". There is a table already in the database "dbo.Countries" with a spatial column. When I run the query with overwrites, this existing table gets deleted and schema1.Countries is created. If overwrites are off, schema1.Counties is not imported. If I have two objects in the database already called "Countries" with different schema "dbo" and "schema2", one of them is deleted when I try to import a new object.
I have resorted to creating a new database (rather than schemas) for each mapping source I want to import from so nothing existing is over written and everything gets imported.
Change History (7)
comment:1 by , 10 years ago
Component: | default → OGR_SF |
---|---|
Owner: | changed from | to
comment:2 by , 10 years ago
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'll have to reopen this issue. If you execute the following commands:
ogr2ogr -overwrite -lco OVERWRITE=YES -lco SCHEMA="dbo" -nln "roads" -a_srs EPSG:25832 -f "MSSQLSpatial" MSSQL:"server=s-gis;database=test;trusted_connection=yes" "T:\GIS\winter_roads.tab" ogr2ogr -overwrite -lco OVERWRITE=YES -lco SCHEMA="winter" -nln "roads" -a_srs EPSG:25832 -f "MSSQLSpatial" MSSQL:"server=s-gis;database=test;trusted_connection=yes" "T:\GIS\winter_roads.tab"
You would expect that 2 tables in the database "test" on server "s-gis": "roads" in schema "dbo" and "roads" in schema "winter" would be created (or overwrited). However after the commands there is only one table in the database: "roads" in schema "winter".
If you however reverse the order of the commands, it behaves as expected; there is two tables in the database.
If you only execute the first command, it will create a table "roads" in "dbo" .
The commands is tested on GDAL trunk from the gisinternals site, build date 2015-11-02
comment:7 by , 5 years ago
Milestone: | → closed_because_of_github_migration |
---|---|
Resolution: | → wontfix |
Status: | reopened → closed |
This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.
The "create spatial index" and "drop spatial index" statements don't work either with named schemas.