Skip to content
Permalink
Browse files

Fixed test for int4 where clause (pgsql)

Turns out the DBMS won't return a type name of "int", but "int4". We
changed the test accordingly to reflect what QGIS should expect from the
database.
  • Loading branch information
espinafre authored and nyalldawson committed Jun 17, 2020
1 parent 617e0db commit 44f4afe023039a7e75db47f85d0af3aad05a1c60
Showing with 2 additions and 4 deletions.
  1. +2 −4 tests/src/providers/testqgspostgresprovider.cpp
@@ -207,7 +207,7 @@ void TestQgsPostgresProvider::testQuotedValueBigInt()
// 4 byte integer
f0.setName( "fld_integer" );
f0.setType( QVariant::Int );
f0.setTypeName( "int" );
f0.setTypeName( "int4" );

fields.append( f0 );
pkAttrs.append( 0 );
@@ -292,9 +292,7 @@ void TestQgsPostgresProvider::testQuotedValueBigInt()
sdata->clear();
sdata->insertFid( 1LL, vlst );

// 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\"=42" ) );
}

QGSTEST_MAIN( TestQgsPostgresProvider )

0 comments on commit 44f4afe

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