Skip to content

Commit 6faf04d

Browse files
author
jef
committed
reindent postgres provider
git-svn-id: http://svn.osgeo.org/qgis/trunk@10968 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6386084 commit 6faf04d

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/providers/postgres/qgspostgresprovider.cpp

+41-41
Original file line numberDiff line numberDiff line change
@@ -1686,8 +1686,8 @@ void QgsPostgresProvider::enumValues( int index, QStringList& enumList )
16861686

16871687
QString typeName;
16881688
//find out type of index
1689-
QgsFieldMap::const_iterator f_it = attributeFields.find(index);
1690-
if(f_it != attributeFields.constEnd())
1689+
QgsFieldMap::const_iterator f_it = attributeFields.find( index );
1690+
if ( f_it != attributeFields.constEnd() )
16911691
{
16921692
typeName = f_it.value().typeName();
16931693
}
@@ -1697,57 +1697,57 @@ void QgsPostgresProvider::enumValues( int index, QStringList& enumList )
16971697
}
16981698

16991699
//is type an enum?
1700-
QString typeSql = QString("SELECT typtype FROM pg_type where typname = %1").arg(quotedValue(typeName));
1700+
QString typeSql = QString( "SELECT typtype FROM pg_type where typname = %1" ).arg( quotedValue( typeName ) );
17011701
Result typeRes = connectionRO->PQexec( typeSql );
1702-
if ( PQresultStatus( typeRes ) != PGRES_TUPLES_OK || PQntuples(typeRes) < 1)
1702+
if ( PQresultStatus( typeRes ) != PGRES_TUPLES_OK || PQntuples( typeRes ) < 1 )
17031703
{
17041704
return;
17051705
}
17061706

17071707

17081708
QString typtype = PQgetvalue( typeRes, 0, 0 );
1709-
if(typtype.compare("e", Qt::CaseInsensitive) == 0)
1709+
if ( typtype.compare( "e", Qt::CaseInsensitive ) == 0 )
17101710
{
17111711
//try to read enum_range of attribute
1712-
if(!parseEnumRange(enumList, f_it->name()))
1712+
if ( !parseEnumRange( enumList, f_it->name() ) )
17131713
{
17141714
enumList.clear();
17151715
}
17161716
}
17171717
else
17181718
{
17191719
//is there a domain check constraint for the attribute?
1720-
if(!parseDomainCheckConstraint(enumList, f_it->name()))
1720+
if ( !parseDomainCheckConstraint( enumList, f_it->name() ) )
17211721
{
1722-
enumList.clear();
1722+
enumList.clear();
17231723
}
17241724
}
17251725
}
17261726

1727-
bool QgsPostgresProvider::parseEnumRange(QStringList& enumValues, const QString& attributeName) const
1727+
bool QgsPostgresProvider::parseEnumRange( QStringList& enumValues, const QString& attributeName ) const
17281728
{
17291729
enumValues.clear();
1730-
QString enumRangeSql = QString("SELECT enum_range(%1) from %2 limit1").arg(quotedIdentifier(attributeName)).arg(mSchemaTableName);
1731-
Result enumRangeRes = connectionRO->PQexec(enumRangeSql);
1732-
if ( PQresultStatus( enumRangeRes ) == PGRES_TUPLES_OK && PQntuples(enumRangeRes) > 0)
1730+
QString enumRangeSql = QString( "SELECT enum_range(%1) from %2 limit1" ).arg( quotedIdentifier( attributeName ) ).arg( mSchemaTableName );
1731+
Result enumRangeRes = connectionRO->PQexec( enumRangeSql );
1732+
if ( PQresultStatus( enumRangeRes ) == PGRES_TUPLES_OK && PQntuples( enumRangeRes ) > 0 )
17331733
{
1734-
QString enumRangeString = PQgetvalue(enumRangeRes, 0, 0);
1734+
QString enumRangeString = PQgetvalue( enumRangeRes, 0, 0 );
17351735
//strip away the brackets at begin and end
1736-
enumRangeString.chop(1);
1737-
enumRangeString.remove(0, 1);
1738-
QStringList rangeSplit = enumRangeString.split(",");
1736+
enumRangeString.chop( 1 );
1737+
enumRangeString.remove( 0, 1 );
1738+
QStringList rangeSplit = enumRangeString.split( "," );
17391739
QStringList::const_iterator range_it = rangeSplit.constBegin();
1740-
for(; range_it != rangeSplit.constEnd(); ++range_it)
1740+
for ( ; range_it != rangeSplit.constEnd(); ++range_it )
17411741
{
17421742
QString currentEnumValue = *range_it;
17431743
//remove quotes from begin and end of the value
1744-
if(currentEnumValue.startsWith("'") || currentEnumValue.startsWith("\""))
1744+
if ( currentEnumValue.startsWith( "'" ) || currentEnumValue.startsWith( "\"" ) )
17451745
{
1746-
currentEnumValue.remove(0, 1);
1746+
currentEnumValue.remove( 0, 1 );
17471747
}
1748-
if(currentEnumValue.endsWith("'") || currentEnumValue.endsWith("\""))
1748+
if ( currentEnumValue.endsWith( "'" ) || currentEnumValue.endsWith( "\"" ) )
17491749
{
1750-
currentEnumValue.chop(1);
1750+
currentEnumValue.chop( 1 );
17511751
}
17521752
enumValues << currentEnumValue;
17531753
}
@@ -1756,49 +1756,49 @@ bool QgsPostgresProvider::parseEnumRange(QStringList& enumValues, const QString&
17561756
return false;
17571757
}
17581758

1759-
bool QgsPostgresProvider::parseDomainCheckConstraint(QStringList& enumValues, const QString& attributeName) const
1759+
bool QgsPostgresProvider::parseDomainCheckConstraint( QStringList& enumValues, const QString& attributeName ) const
17601760
{
17611761
enumValues.clear();
17621762

17631763
//is it a domain type with a check constraint?
1764-
QString domainSql = QString("SELECT domain_name from information_schema.columns where table_name = %1 and column_name = %2").arg(quotedValue(mTableName)).arg(quotedValue(attributeName));
1765-
Result domainResult = connectionRO->PQexec(domainSql);
1766-
if ( PQresultStatus( domainResult ) == PGRES_TUPLES_OK && PQntuples(domainResult) > 0)
1764+
QString domainSql = QString( "SELECT domain_name from information_schema.columns where table_name = %1 and column_name = %2" ).arg( quotedValue( mTableName ) ).arg( quotedValue( attributeName ) );
1765+
Result domainResult = connectionRO->PQexec( domainSql );
1766+
if ( PQresultStatus( domainResult ) == PGRES_TUPLES_OK && PQntuples( domainResult ) > 0 )
17671767
{
17681768
//a domain type
1769-
QString domainCheckDefinitionSql = QString("SELECT consrc FROM pg_constraint where conname = (SELECT constraint_name FROM information_schema.domain_constraints WHERE domain_name = %1)").arg(quotedValue(PQgetvalue(domainResult, 0, 0)));
1770-
Result domainCheckRes = connectionRO->PQexec(domainCheckDefinitionSql);
1771-
if ( PQresultStatus(domainCheckRes) == PGRES_TUPLES_OK && PQntuples(domainCheckRes) > 0)
1769+
QString domainCheckDefinitionSql = QString( "SELECT consrc FROM pg_constraint where conname = (SELECT constraint_name FROM information_schema.domain_constraints WHERE domain_name = %1)" ).arg( quotedValue( PQgetvalue( domainResult, 0, 0 ) ) );
1770+
Result domainCheckRes = connectionRO->PQexec( domainCheckDefinitionSql );
1771+
if ( PQresultStatus( domainCheckRes ) == PGRES_TUPLES_OK && PQntuples( domainCheckRes ) > 0 )
17721772
{
1773-
QString checkDefinition = PQgetvalue(domainCheckRes, 0, 0);
1773+
QString checkDefinition = PQgetvalue( domainCheckRes, 0, 0 );
17741774

17751775
//we assume that the constraint is of the following form:
17761776
//(VALUE = ANY (ARRAY['a'::text, 'b'::text, 'c'::text, 'd'::text]))
17771777
//normally, postgresql creates that if the contstraint has been specified as 'VALUE in ('a', 'b', 'c', 'd')
17781778

17791779
//todo: ANY must occure before ARRAY
1780-
int anyPos = checkDefinition.indexOf("VALUE = ANY");
1781-
int arrayPosition = checkDefinition.lastIndexOf("ARRAY[");
1782-
int closingBracketPos = checkDefinition.indexOf("]", arrayPosition + 6);
1780+
int anyPos = checkDefinition.indexOf( "VALUE = ANY" );
1781+
int arrayPosition = checkDefinition.lastIndexOf( "ARRAY[" );
1782+
int closingBracketPos = checkDefinition.indexOf( "]", arrayPosition + 6 );
17831783

1784-
if(anyPos == -1 || anyPos >= arrayPosition)
1784+
if ( anyPos == -1 || anyPos >= arrayPosition )
17851785
{
17861786
return false; //constraint has not the required format
17871787
}
17881788

1789-
if(arrayPosition != -1)
1789+
if ( arrayPosition != -1 )
17901790
{
1791-
QString valueList = checkDefinition.mid(arrayPosition + 6, closingBracketPos);
1792-
QStringList commaSeparation = valueList.split(",", QString::SkipEmptyParts);
1791+
QString valueList = checkDefinition.mid( arrayPosition + 6, closingBracketPos );
1792+
QStringList commaSeparation = valueList.split( ",", QString::SkipEmptyParts );
17931793
QStringList::const_iterator cIt = commaSeparation.constBegin();
1794-
for(; cIt != commaSeparation.constEnd(); ++cIt)
1794+
for ( ; cIt != commaSeparation.constEnd(); ++cIt )
17951795
{
17961796
//get string between ''
1797-
int beginQuotePos = cIt->indexOf("'");
1798-
int endQuotePos = cIt->lastIndexOf("'");
1799-
if(beginQuotePos != -1 && (endQuotePos - beginQuotePos) > 1)
1797+
int beginQuotePos = cIt->indexOf( "'" );
1798+
int endQuotePos = cIt->lastIndexOf( "'" );
1799+
if ( beginQuotePos != -1 && ( endQuotePos - beginQuotePos ) > 1 )
18001800
{
1801-
enumValues << cIt->mid(beginQuotePos + 1, endQuotePos - beginQuotePos - 1);
1801+
enumValues << cIt->mid( beginQuotePos + 1, endQuotePos - beginQuotePos - 1 );
18021802
}
18031803
}
18041804
}

0 commit comments

Comments
 (0)