Skip to content

Commit

Permalink
the test for uniqueness now also works for multiple columns
Browse files Browse the repository at this point in the history
  • Loading branch information
SebDieBln authored and jef-n committed Oct 17, 2015
1 parent a4124da commit ab943f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,12 +1314,12 @@ void QgsPostgresProvider::determinePrimaryKeyFromUriKeyColumn()
}
}

bool QgsPostgresProvider::uniqueData( QString query, QString quotedColName )
bool QgsPostgresProvider::uniqueData( QString query, QString quotedColNames )
{
Q_UNUSED( query );
// Check to see if the given column contains unique data
QString sql = QString( "SELECT count(distinct %1)=count(%1) FROM %2%3" )
.arg( quotedColName,
// Check to see if the given columns contain unique data
QString sql = QString( "SELECT count(distinct (%1))=count((%1)) AND bool_and((%1) IS NOT NULL) FROM %2%3" )
.arg( quotedColNames,
mQuery,
filterWhereClause() );

Expand Down
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgresprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
QString mWhat;
};

// A function that determines if the given schema.table.column
// contains unqiue entries
bool uniqueData( QString query, QString colName );
// A function that determines if the given columns
// contain unique entries
bool uniqueData( QString query, QString quotedColNames );

int mEnabledCapabilities;

Expand Down

0 comments on commit ab943f8

Please sign in to comment.