|
| 1 | +/*************************************************************************** |
| 2 | + qgsoracleexpressioncompiler.cpp |
| 3 | + ---------------------------------------------------- |
| 4 | + date : December 2015 |
| 5 | + copyright : (C) 2015 by Juergen E. Fischer |
| 6 | + email : jef at norbit dot de |
| 7 | + *************************************************************************** |
| 8 | + * * |
| 9 | + * This program is free software; you can redistribute it and/or modify * |
| 10 | + * it under the terms of the GNU General Public License as published by * |
| 11 | + * the Free Software Foundation; either version 2 of the License, or * |
| 12 | + * (at your option) any later version. * |
| 13 | + * * |
| 14 | + ***************************************************************************/ |
| 15 | + |
| 16 | +#include "qgsoracleexpressioncompiler.h" |
| 17 | +#include "qgssqlexpressioncompiler.h" |
| 18 | + |
| 19 | +QgsOracleExpressionCompiler::QgsOracleExpressionCompiler( QgsOracleFeatureSource* source ) |
| 20 | + : QgsSqlExpressionCompiler( source->mFields ) |
| 21 | +{ |
| 22 | +} |
| 23 | + |
| 24 | +QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const QgsExpression::Node* node, QString& result ) |
| 25 | +{ |
| 26 | + if ( node->nodeType() == QgsExpression::ntBinaryOperator ) |
| 27 | + { |
| 28 | + const QgsExpression::NodeBinaryOperator *bin( static_cast<const QgsExpression::NodeBinaryOperator*>( node ) ); |
| 29 | + |
| 30 | + switch ( bin->op() ) |
| 31 | + { |
| 32 | + case QgsExpression::boPow: |
| 33 | + case QgsExpression::boRegexp: |
| 34 | + { |
| 35 | + QString op1, op2; |
| 36 | + |
| 37 | + if ( compileNode( bin->opLeft(), op1 ) != Complete || |
| 38 | + compileNode( bin->opRight(), op2 ) != Complete ) |
| 39 | + return Fail; |
| 40 | + |
| 41 | + switch ( bin->op() ) |
| 42 | + { |
| 43 | + case QgsExpression::boPow: |
| 44 | + result = QString( "power(%1,%2)" ).arg( op1, op2 ); |
| 45 | + return Complete; |
| 46 | + |
| 47 | + case QgsExpression::boRegexp: |
| 48 | + result = QString( "regexp_like(%1,%2)" ).arg( op1, op2 ); |
| 49 | + return Complete; |
| 50 | + |
| 51 | + default: |
| 52 | + break; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + default: |
| 57 | + break; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + //fallback to default handling |
| 62 | + return QgsSqlExpressionCompiler::compileNode( node, result ); |
| 63 | +} |
| 64 | + |
| 65 | +QString QgsOracleExpressionCompiler::quotedIdentifier( const QString& identifier ) |
| 66 | +{ |
| 67 | + return QgsOracleConn::quotedIdentifier( identifier ); |
| 68 | +} |
| 69 | + |
| 70 | +QString QgsOracleExpressionCompiler::quotedValue( const QVariant& value ) |
| 71 | +{ |
| 72 | + return QgsOracleConn::quotedValue( value ); |
| 73 | +} |
0 commit comments