2013-10-11 23:07:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 - Juan Ferrer Toribio
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SQL_SELECT_H
|
|
|
|
#define SQL_SELECT_H
|
|
|
|
|
|
|
|
#include "sql-dml.h"
|
|
|
|
|
|
|
|
#define SQL_TYPE_SELECT (sql_select_get_type ())
|
|
|
|
#define SQL_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_SELECT, SqlSelect))
|
|
|
|
#define SQL_IS_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_SELECT))
|
|
|
|
|
|
|
|
typedef struct _SqlSelect SqlSelect;
|
|
|
|
typedef struct _SqlSelectClass SqlSelectClass;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SQL_SELECT_NONE
|
|
|
|
,SQL_SELECT_UNION_ALL
|
|
|
|
,SQL_SELECT_UNION_ANY
|
|
|
|
,SQL_SELECT_INTERSECT
|
|
|
|
,SQL_SELECT_EXCEPT
|
|
|
|
,SQL_SELECT_COUNT
|
|
|
|
}
|
|
|
|
SqlSelectType;
|
|
|
|
|
2013-10-14 12:08:06 +00:00
|
|
|
/**
|
|
|
|
* SqlOrderWay:
|
|
|
|
* @SQL_ORDER_ASC: ascendent order
|
|
|
|
* @SQL_ORDER_DESC: descendent order
|
|
|
|
**/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SQL_ORDER_ASC
|
|
|
|
,SQL_ORDER_DESC
|
|
|
|
}
|
|
|
|
SqlOrderWay;
|
|
|
|
|
2013-10-11 23:07:35 +00:00
|
|
|
/**
|
|
|
|
* SqlSelect:
|
|
|
|
* @expr: (element-type Sql.Expr):
|
|
|
|
* @group: (element-type Sql.Expr):
|
|
|
|
* @order: (element-type Sql.Expr):
|
|
|
|
**/
|
|
|
|
struct _SqlSelect
|
|
|
|
{
|
|
|
|
SqlDml parent;
|
|
|
|
gboolean distinct;
|
2013-10-14 12:08:06 +00:00
|
|
|
GSList * expr;
|
|
|
|
GSList * alias; // List of Sql.SelectAlias
|
|
|
|
GSList * group;
|
2013-10-11 23:07:35 +00:00
|
|
|
SqlExpr * having;
|
2013-10-14 12:08:06 +00:00
|
|
|
GSList * order;
|
2013-10-11 23:07:35 +00:00
|
|
|
guint limit_offset;
|
|
|
|
guint limit_count;
|
|
|
|
|
|
|
|
SqlSelectType type;
|
2013-10-14 12:08:06 +00:00
|
|
|
SqlSelect * next;
|
2013-10-11 23:07:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _SqlSelectClass
|
|
|
|
{
|
|
|
|
/* <private> */
|
|
|
|
SqlDmlClass parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
GType sql_select_get_type ();
|
2013-10-14 12:08:06 +00:00
|
|
|
SqlSelect * sql_select_new ();
|
2013-10-11 23:07:35 +00:00
|
|
|
void sql_select_set_distinct (SqlSelect * obj, gboolean distinct);
|
|
|
|
void sql_select_add_expr (SqlSelect * obj, SqlExpr * expr);
|
|
|
|
void sql_select_set_alias (SqlSelect * obj, SqlExpr * expr, const gchar * alias);
|
2013-12-13 09:07:52 +00:00
|
|
|
gchar * sql_select_get_column_name (SqlSelect * obj, SqlExpr * expr);
|
2013-10-11 23:07:35 +00:00
|
|
|
void sql_select_add_group (SqlSelect * obj, SqlExpr * expr);
|
|
|
|
void sql_select_set_having (SqlSelect * obj, SqlExpr * expr);
|
2013-10-14 12:08:06 +00:00
|
|
|
void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlOrderWay way);
|
2013-10-11 23:07:35 +00:00
|
|
|
void sql_select_set_limit (SqlSelect * obj, guint count, guint offset);
|
|
|
|
void sql_select_set_next (SqlSelect * obj, SqlSelect * next, SqlSelectType type);
|
|
|
|
|
|
|
|
#endif
|