25 QgsSQLiteExpressionCompiler::QgsSQLiteExpressionCompiler(
const QgsFields &fields )
48 if ( compileNode( op->
opLeft(), opL ) != Complete ||
49 compileNode( op->
opRight(), opR ) != Complete )
52 result = QStringLiteral(
"lower(%1) %2 lower(%3) ESCAPE '\\'" )
71 if ( fd->
name() == QLatin1String(
"make_datetime" ) || fd->
name() == QLatin1String(
"make_date" ) || fd->
name() == QLatin1String(
"make_time" ) )
73 const auto constList = n->
args()->
list();
91 QString QgsSQLiteExpressionCompiler::quotedIdentifier(
const QString &identifier )
96 QString QgsSQLiteExpressionCompiler::quotedValue(
const QVariant &value,
bool &ok )
102 QString QgsSQLiteExpressionCompiler::sqlFunctionFromFunctionName(
const QString &fnName )
const
104 static const QMap<QString, QString> FN_NAMES
108 {
"coalesce",
"coalesce" },
109 {
"lower",
"lower" },
110 {
"round",
"round" },
112 {
"upper",
"upper" },
113 {
"make_datetime",
"" },
118 return FN_NAMES.value( fnName, QString() );
121 QStringList QgsSQLiteExpressionCompiler::sqlArgumentsFromFunctionName(
const QString &fnName,
const QStringList &fnArgs )
const
123 QStringList args( fnArgs );
124 if ( fnName == QLatin1String(
"make_datetime" ) )
126 args = QStringList( QStringLiteral(
"'%1-%2-%3T%4:%5:%6Z'" ).arg( args[0].rightJustified( 4,
'0' ) )
127 .arg( args[1].rightJustified( 2,
'0' ) )
128 .arg( args[2].rightJustified( 2,
'0' ) )
129 .arg( args[3].rightJustified( 2,
'0' ) )
130 .arg( args[4].rightJustified( 2,
'0' ) )
131 .arg( args[5].rightJustified( 2,
'0' ) ) );
133 else if ( fnName == QLatin1String(
"make_date" ) )
135 args = QStringList( QStringLiteral(
"'%1-%2-%3'" ).arg( args[0].rightJustified( 4,
'0' ) )
136 .arg( args[1].rightJustified( 2,
'0' ) )
137 .arg( args[2].rightJustified( 2,
'0' ) ) );
139 else if ( fnName == QLatin1String(
"make_time" ) )
141 args = QStringList( QStringLiteral(
"'%1:%2:%3'" ).arg( args[0].rightJustified( 2,
'0' ) )
142 .arg( args[1].rightJustified( 2,
'0' ) )
143 .arg( args[2].rightJustified( 2,
'0' ) ) );
148 QString QgsSQLiteExpressionCompiler::castToReal(
const QString &value )
const
150 return QStringLiteral(
"CAST((%1) AS REAL)" ).arg( value );
153 QString QgsSQLiteExpressionCompiler::castToInt(
const QString &value )
const
155 return QStringLiteral(
"CAST((%1) AS INTEGER)" ).arg( value );
158 QString QgsSQLiteExpressionCompiler::castToText(
const QString &value )
const
160 return QStringLiteral(
"CAST((%1) AS TEXT)" ).arg( value );