mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
parent
6ca436d1fd
commit
8d9565099a
@ -294,7 +294,12 @@ QList<QVariantList> QgsPostgresProviderConnection::executeSqlPrivate( const QStr
|
||||
{
|
||||
const QVariant::Type vType { typeMap.value( colIdx, QVariant::Type::String ) };
|
||||
QVariant val { res.PQgetvalue( rowIdx, colIdx ) };
|
||||
if ( val.canConvert( static_cast<int>( vType ) ) )
|
||||
// Special case for bools: 'f' and 't'
|
||||
if ( vType == QVariant::Bool )
|
||||
{
|
||||
val = val.toString() == 't';
|
||||
}
|
||||
else if ( val.canConvert( static_cast<int>( vType ) ) )
|
||||
{
|
||||
val.convert( static_cast<int>( vType ) );
|
||||
}
|
||||
|
@ -177,6 +177,14 @@ class TestPyQgsProviderConnectionPostgres(unittest.TestCase, TestPyQgsProviderCo
|
||||
self.assertFalse('Raster2' in table_names)
|
||||
self.assertTrue('Raster1' in table_names)
|
||||
|
||||
def test_true_false(self):
|
||||
"""Test returned values from BOOL queries"""
|
||||
|
||||
md = QgsProviderRegistry.instance().providerMetadata(self.providerKey)
|
||||
conn = md.createConnection(self.uri, {})
|
||||
self.assertEqual(conn.executeSql('SELECT FALSE'), [[False]])
|
||||
self.assertEqual(conn.executeSql('SELECT TRUE'), [[True]])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user