diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-12-12 11:59:53 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-12-16 21:32:26 +0100 |
commit | ab864bd178a44208c98a2fd1b1248df5f1db1fc9 (patch) | |
tree | 424c97147b72d264f2f12aacbe07d57c242c3c84 /connectivity/source/drivers/evoab2/NStatement.cxx | |
parent | 00ba09e5675fd30032d0fba38212dcad1a696e73 (diff) |
tdf#38235: fix sort failure for Evolution
Several issues to deal with:
1) The initial pb:
"Error setting the source criteria. The column XXX must be visible as a column. SQL status: 01000, Error code 1000."
=>
OEvoabResultSetMetaData::getColumnLabel was returning the nickname of the column with g_param_spec_get_nick
we just want the column name to display and to use
2) SQL parsing in OCommonStatement::orderByAnalysis
2 "sub-issues":
a) ENSURE_OR_THROW was testing SQL_ISRULE( pAscDesc, opt_asc_desc )
opt_asc_desc is defined in connectivity/source/parse/sqlbison.y with:
opt_asc_desc:
{$$ = SQL_NEW_RULE;}
| SQL_TOKEN_ASC
| SQL_TOKEN_DESC
;
not sure if it should be kept but for DESC I had to use this:
SQL_ISTOKEN(pAscDesc, DESC)
b) Retrieve of ascending
By default ascending is at true but then we tested the node with:
if ( ( pAscDesc->count() == 1 ) && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC )
But when we use DESC, it's directly a TOKEN so just this should suffice:
bool bAscending = !SQL_ISTOKEN(pAscDesc, DESC);
3) CompareContacts wasn't taking into account bAscending
since we use comparison function for g_slist_sort_with_data, I only used
int nOrder = 1;
// if descending sort, reverse order
if (!sortCol.bAscending)
nOrder = -1;
and multiply the result with this to have the ad hoc order
Change-Id: I3c360a5ef9cf0dc737a7ce4a138d2d2586abdca9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126698
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity/source/drivers/evoab2/NStatement.cxx')
-rw-r--r-- | connectivity/source/drivers/evoab2/NStatement.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index 542ee1de8d45..1f3e21a2ef90 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -268,8 +268,11 @@ void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, So ENSURE_OR_THROW( ( pColumnRef != nullptr ) && ( pAscDesc != nullptr ) - && SQL_ISRULE( pAscDesc, opt_asc_desc ) - && ( pAscDesc->count() < 2 ), + && ( pAscDesc->isLeaf() ) + && ( SQL_ISRULE( pAscDesc, opt_asc_desc ) + || SQL_ISTOKEN(pAscDesc, ASC) + || SQL_ISTOKEN(pAscDesc, DESC) + ), "ordering_spec structure error" ); // column name -> column field @@ -278,11 +281,7 @@ void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, So const OUString sColumnName( impl_getColumnRefColumnName_throw( *pColumnRef ) ); guint nField = evoab::findEvoabField( sColumnName ); // ascending/descending? - bool bAscending = true; - if ( ( pAscDesc->count() == 1 ) - && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC ) - ) - bAscending = false; + bool bAscending = !SQL_ISTOKEN(pAscDesc, DESC); _out_rSort.push_back( FieldSort( nField, bAscending ) ); } @@ -506,6 +505,7 @@ void OCommonStatement::parseSql( const OUString& sql, QueryData& _out_rQueryData pOrderByClause->showParseTree( sTreeDebug ); SAL_INFO( "connectivity.evoab2", "found order-by tree:\n" << sTreeDebug ); #endif + orderByAnalysis( pOrderByClause, _out_rQueryData.aSortOrder ); } |