Skip to content

Commit

Permalink
Postgres/SQLite/MSSQL provider: fix addAttributes() fail (wrong synta…
Browse files Browse the repository at this point in the history
…x/empty statement) when argument is an empty list
  • Loading branch information
brushtyler committed Aug 25, 2015
1 parent fdb0d20 commit 762d28b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,9 @@ bool QgsMssqlProvider::addAttributes( const QList<QgsField> &attributes )
{
QString statement;

if ( attributes.count() == 0 )
return true;

for ( QList<QgsField>::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
{
QString type = it->typeName();
Expand Down
3 changes: 3 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,9 @@ bool QgsPostgresProvider::addAttributes( const QList<QgsField> &attributes )
if ( mIsQuery )
return false;

if ( attributes.count() == 0 )
return true;

QgsPostgresConn* conn = connectionRW();
if ( !conn )
{
Expand Down
3 changes: 3 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3797,6 +3797,9 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList<QgsField> &attributes )
bool toCommit = false;
QString sql;

if ( attributes.count() == 0 )
return true;

int ret = sqlite3_exec( sqliteHandle, "BEGIN", NULL, NULL, &errMsg );
if ( ret != SQLITE_OK )
{
Expand Down

0 comments on commit 762d28b

Please sign in to comment.