Skip to content

Commit

Permalink
Changed tests after rebasing on top of 7120e5d
Browse files Browse the repository at this point in the history
That change made a few improvements, and uncovered a bug in handling
tables with composite primary keys if one component is an integer.
  • Loading branch information
espinafre authored and nyalldawson committed Jun 11, 2020
1 parent 952542a commit 2a2188e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/src/providers/testqgspostgresprovider.cpp
Expand Up @@ -256,7 +256,7 @@ void TestQgsPostgresProvider::testQuotedValueBigInt()
sdata = new QgsPostgresSharedData;
sdata->insertFid( 1LL, vlst );

QCOMPARE( QgsPostgresUtils::whereClause( 1LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr<QgsPostgresSharedData>( sdata ) ), QString( "\"fld_double\"::text='3.141592741'" ) );
QCOMPARE( QgsPostgresUtils::whereClause( 1LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr<QgsPostgresSharedData>( sdata ) ), QString( "\"fld_double\"=3.141592741" ) );

// text
f3.setName( "fld_text" );
Expand Down Expand Up @@ -296,9 +296,9 @@ void TestQgsPostgresProvider::testQuotedValueBigInt()
sdata = new QgsPostgresSharedData;
sdata->insertFid( 1LL, vlst );

// TODO: FIXME: Please don't cast integer primary key types to text if they are part of a FidMap!
// TODO: FIXME: in tables with composite PKs, integer fields are cast to text, but their values are not.
// It hurts the database performance badly.
QCOMPARE( QgsPostgresUtils::whereClause( 1LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr<QgsPostgresSharedData>( sdata ) ), QString( "\"fld_bigint\"='-9223372036854775800' AND \"fld_text\"::text='QGIS ''Rocks''!' AND \"fld_integer\"::text='42'" ) );
QCOMPARE( QgsPostgresUtils::whereClause( 1LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr<QgsPostgresSharedData>( sdata ) ), QString( "\"fld_bigint\"=-9223372036854775800 AND \"fld_text\"::text='QGIS ''Rocks''!' AND \"fld_integer\"::text=42" ) );
}

QGSTEST_MAIN( TestQgsPostgresProvider )
Expand Down

0 comments on commit 2a2188e

Please sign in to comment.