Skip to content
Permalink
Browse files

Changed tests after rebasing on top of 7120e5d

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 10, 2020
1 parent 952542a commit 2a2188e58b8b0f3dddb68567cbc69b2eb97d30fb
Showing with 3 additions and 3 deletions.
  1. +3 −3 tests/src/providers/testqgspostgresprovider.cpp
@@ -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" );
@@ -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 )

0 comments on commit 2a2188e

Please sign in to comment.
You can’t perform that action at this time.