[QGIS Commit] r12922 - trunk/qgis/src/app/ogr
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Feb 10 15:17:50 EST 2010
Author: jef
Date: 2010-02-10 15:17:49 -0500 (Wed, 10 Feb 2010)
New Revision: 12922
Modified:
trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp
Log:
fix #2009
Modified: trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp
===================================================================
--- trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp 2010-02-10 19:19:33 UTC (rev 12921)
+++ trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp 2010-02-10 20:17:49 UTC (rev 12922)
@@ -24,6 +24,7 @@
QString createDatabaseURI( QString connectionType, QString host, QString database, QString port, QString user, QString password )
{
QString uri = "";
+
//todo:add default ports for all kind of databases
if ( connectionType == "ESRI Personal GeoDatabase" )
{
@@ -31,28 +32,58 @@
}
else if ( connectionType == "ESRI ArcSDE" )
{
- if ( port.isNull() || port.isEmpty() )
+ if ( port.isEmpty() )
port = "5151";
+
uri = "SDE:" + host + ",PORT:" + port + "," + database + "," + user + "," + password;
}
else if ( connectionType == "Informix DataBlade" )
{
//not tested
- uri = "IDB:dbname=" + database + " server=" + host
- + " user=" + user
- + " pass=" + password + " ";
+ uri = "IDB:dbname=" + database;
+ if ( !host.isEmpty() )
+ uri += QString( " server=%1" ).arg( host );
+
+ if ( !user.isEmpty() )
+ {
+ uri += QString( " user=%1" ).arg( user );
+
+ if ( !password.isEmpty() )
+ uri += QString( " pass=%1" ).arg( password );
+ }
}
else if ( connectionType == "INGRES" )
{
//not tested
- uri = "@driver=ingres,dbname=" + database + ",userid=" + user + ", password=" + password + " ";
+ uri = "@driver=ingres,dbname=" + database;
+ if ( !user.isEmpty() )
+ {
+ uri += QString( ",userid=%1" ).arg( user );
+
+ if ( !password.isEmpty() )
+ uri += QString( ",password=%1" ).arg( password );
+ }
}
else if ( connectionType == "MySQL" )
{
- uri = "MySQL:" + database + ",host=" + host
- + ",port=" + port + ",user=" + user
- + ", password=" + password + " ";
+ uri = "MySQL:" + database;
+
+ if ( !host.isEmpty() )
+ {
+ uri += QString( ",host=%1" ).arg( host );
+
+ if ( !port.isEmpty() )
+ uri += QString( ",port=%1" ).arg( port );
+ }
+
+ if ( !user.isEmpty() )
+ {
+ uri += QString( ",user=%1" ).arg( user );
+
+ if ( !password.isEmpty() )
+ uri += QString( ",password=%1" ).arg( password );
+ }
}
else if ( connectionType == "Oracle Spatial" )
{
@@ -97,11 +128,27 @@
}
else if ( connectionType == "PostgreSQL" )
{
- uri = "PG:dbname='" + database + "' host='" + host
- + "' port='" + port + "' user='" + user
- + "' password='" + password + "' ";
+ uri = "PG:dbname='" + database + "'";
+ if ( !host.isEmpty() )
+ {
+ uri += QString( " host='%1'" ).arg( host );
+
+ if ( !port.isEmpty() )
+ uri += QString( " port='%1'" ).arg( port );
+ }
+
+ if ( !user.isEmpty() )
+ {
+ uri += QString( " user='%1'" ).arg( user );
+
+ if ( !password.isEmpty() )
+ uri += QString( " password='%1'" ).arg( password );
+ }
+
+ uri += " ";
}
+
QgsDebugMsg( "Connection type is=" + connectionType + " and uri=" + uri );
return uri;
}
More information about the QGIS-commit
mailing list