Skip to content

Commit ab943f8

Browse files
SebDieBlnjef-n
authored andcommitted
the test for uniqueness now also works for multiple columns
1 parent a4124da commit ab943f8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,12 @@ void QgsPostgresProvider::determinePrimaryKeyFromUriKeyColumn()
13141314
}
13151315
}
13161316

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

src/providers/postgres/qgspostgresprovider.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
456456
QString mWhat;
457457
};
458458

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

463463
int mEnabledCapabilities;
464464

0 commit comments

Comments
 (0)