Skip to content

Commit

Permalink
quote closing parens within column names (fixes #7159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 15, 2013
1 parent c036e7e commit b630692
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/qgsdatasourceuri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,20 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
int start = i;
QString col;
while ( i < uri.length() && uri[i] != ')' )
{
if ( uri[i] == '\\' )
i++;
i++;
}

if ( i == uri.length() )
{
QgsDebugMsg( "closing parenthesis missing" );
}

mGeometryColumn = uri.mid( start, i - start );
mGeometryColumn.replace( "\\)", ")" );
mGeometryColumn.replace( "\\\\", "\\" );

i++;
}
Expand Down Expand Up @@ -584,9 +590,13 @@ QString QgsDataSourceURI::uri() const
theUri += QString( " selectatid=false" );
}

QString columnName( mGeometryColumn );
columnName.replace( "\\", "\\\\" );
columnName.replace( ")", "\\)" );

theUri += QString( " table=%1%2 sql=%3" )
.arg( quotedTablename() )
.arg( mGeometryColumn.isNull() ? QString() : QString( " (%1)" ).arg( mGeometryColumn ) )
.arg( mGeometryColumn.isNull() ? QString() : QString( " (%1)" ).arg( columnName ) )
.arg( mSql );

return theUri;
Expand Down

0 comments on commit b630692

Please sign in to comment.