@@ -1768,7 +1768,14 @@ QVariant QgsPostgresProvider::minimumValue( int index ) const
1768
1768
sql = QStringLiteral ( " SELECT %1 FROM (%2) foo" ).arg ( connectionRO ()->fieldExpression ( fld ), sql );
1769
1769
1770
1770
QgsPostgresResult rmin ( connectionRO ()->PQexec ( sql ) );
1771
- return convertValue ( fld.type (), fld.subType (), rmin.PQgetvalue ( 0 , 0 ), fld.typeName () );
1771
+ if ( fld.type () == QVariant::LongLong )
1772
+ {
1773
+ return convertValue ( fld.type (), fld.subType (), QString::number ( connectionRO ()->getBinaryInt ( rmin, 0 , 0 ) ), fld.typeName () );
1774
+ }
1775
+ else
1776
+ {
1777
+ return convertValue ( fld.type (), fld.subType (), rmin.PQgetvalue ( 0 , 0 ), fld.typeName () );
1778
+ }
1772
1779
}
1773
1780
catch ( PGFieldNotFound )
1774
1781
{
@@ -2033,7 +2040,14 @@ QVariant QgsPostgresProvider::maximumValue( int index ) const
2033
2040
2034
2041
QgsPostgresResult rmax ( connectionRO ()->PQexec ( sql ) );
2035
2042
2036
- return convertValue ( fld.type (), fld.subType (), rmax.PQgetvalue ( 0 , 0 ), fld.typeName () );
2043
+ if ( fld.type () == QVariant::LongLong )
2044
+ {
2045
+ return convertValue ( fld.type (), fld.subType (), QString::number ( connectionRO ()->getBinaryInt ( rmax, 0 , 0 ) ), fld.typeName () );
2046
+ }
2047
+ else
2048
+ {
2049
+ return convertValue ( fld.type (), fld.subType (), rmax.PQgetvalue ( 0 , 0 ), fld.typeName () );
2050
+ }
2037
2051
}
2038
2052
catch ( PGFieldNotFound )
2039
2053
{
@@ -2070,7 +2084,16 @@ QVariant QgsPostgresProvider::defaultValue( int fieldId ) const
2070
2084
QgsPostgresResult res ( connectionRO ()->PQexec ( QStringLiteral ( " SELECT %1" ).arg ( defVal ) ) );
2071
2085
2072
2086
if ( res.result () )
2073
- return convertValue ( fld.type (), fld.subType (), res.PQgetvalue ( 0 , 0 ), fld.typeName () );
2087
+ {
2088
+ if ( fld.type () == QVariant::LongLong )
2089
+ {
2090
+ return convertValue ( fld.type (), fld.subType (), QString::number ( connectionRO ()->getBinaryInt ( res, 0 , 0 ) ), fld.typeName () );
2091
+ }
2092
+ else
2093
+ {
2094
+ return convertValue ( fld.type (), fld.subType (), res.PQgetvalue ( 0 , 0 ), fld.typeName () );
2095
+ }
2096
+ }
2074
2097
else
2075
2098
{
2076
2099
pushError ( tr ( " Could not execute query" ) );
0 commit comments