QDjangoWhere.h
/*
* Copyright (C) 2010-2015 Jeremy Lainé
* Contact: https://github.com/jlaine/qdjango
*
* This file is part of the QDjango Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifndef QDJANGO_WHERE_H
#define QDJANGO_WHERE_H
#include <QSharedDataPointer>
#include <QVariant>
#include "QDjango_p.h"
class QDjangoMetaModel;
class QDjangoQuery;
class QDjangoWherePrivate;
class QDJANGO_DB_EXPORT QDjangoWhere
{
public:
enum Operation
{
None,
Equals,
NotEquals,
GreaterThan,
LessThan,
GreaterOrEquals,
LessOrEquals,
StartsWith,
EndsWith,
Contains,
IsIn,
IsNull,
IEquals,
INotEquals,
IStartsWith,
IEndsWith,
IContains
};
QDjangoWhere();
QDjangoWhere(const QDjangoWhere &other);
QDjangoWhere(const QString &key, QDjangoWhere::Operation operation, QVariant value);
~QDjangoWhere();
QDjangoWhere& operator=(const QDjangoWhere &other);
QDjangoWhere operator!() const;
QDjangoWhere operator&&(const QDjangoWhere &other) const;
QDjangoWhere operator||(const QDjangoWhere &other) const;
void bindValues(QDjangoQuery &query) const;
bool isAll() const;
bool isNone() const;
QString sql(const QSqlDatabase &db) const;
QString toString() const;
private:
QSharedDataPointer<QDjangoWherePrivate> d;
friend class QDjangoCompiler;
};
#endif
QDjangoMetaModel
The QDjangoMetaModel class holds the database schema for a model.
Definition: QDjangoMetaModel.h:65
QDjangoWhere
The QDjangoWhere class expresses an SQL constraint.
Definition: QDjangoWhere.h:41
QDjangoWhere::Operation
Operation
A comparison operation on a database column value.
Definition: QDjangoWhere.h:44
QDjangoWhere::Contains
@ Contains
Returns true if the column value contains the given value (strings only).
Definition: QDjangoWhere.h:54
QDjangoWhere::GreaterOrEquals
@ GreaterOrEquals
Returns true if the column value is greater or equal to the given value.
Definition: QDjangoWhere.h:50
QDjangoWhere::StartsWith
@ StartsWith
Returns true if the column value starts with the given value (strings only).
Definition: QDjangoWhere.h:52
QDjangoWhere::INotEquals
@ INotEquals
Returns true if the column value is not equal to the given value (case-insensitive).
Definition: QDjangoWhere.h:58
QDjangoWhere::LessThan
@ LessThan
Returns true if the column value is less than the given value.
Definition: QDjangoWhere.h:49
QDjangoWhere::EndsWith
@ EndsWith
Returns true if the column value ends with the given value (strings only).
Definition: QDjangoWhere.h:53
QDjangoWhere::GreaterThan
@ GreaterThan
Returns true if the column value is greater than the given value.
Definition: QDjangoWhere.h:48
QDjangoWhere::NotEquals
@ NotEquals
Returns true if the column value is not equal to the given value.
Definition: QDjangoWhere.h:47
QDjangoWhere::IStartsWith
@ IStartsWith
Returns true if the column value starts with the given value (strings only, case-insensitive).
Definition: QDjangoWhere.h:59
QDjangoWhere::IEquals
@ IEquals
Returns true if the column value is equal to the given value (case-insensitive)
Definition: QDjangoWhere.h:57
QDjangoWhere::IsIn
@ IsIn
Returns true if the column value is one of the given values.
Definition: QDjangoWhere.h:55
QDjangoWhere::Equals
@ Equals
Returns true if the column value is equal to the given value.
Definition: QDjangoWhere.h:46
QDjangoWhere::LessOrEquals
@ LessOrEquals
Returns true if the column value is less or equal to the given value.
Definition: QDjangoWhere.h:51
QDjangoWhere::IEndsWith
@ IEndsWith
Returns true if the column value ends with the given value (strings only, case-insensitive).
Definition: QDjangoWhere.h:60
QDjangoWhere::None
@ None
No comparison, always returns true.
Definition: QDjangoWhere.h:45
QDjangoWhere::IsNull
@ IsNull
Returns true if the column value is null.
Definition: QDjangoWhere.h:56