Top | ![]() |
![]() |
![]() |
![]() |
gint | cond-type | Read / Write |
GdaQueryJoin * | join | Read / Write |
GdaQuery * | query | Read / Write / Construct Only |
This object represents a condition within a query. Usually there is one such object to express a WHERE condition and sometimes a GdaQueryJoin object con contain one as well to express a specific joinning condition.
There are two types of conditions: 'node' conditions (AND, OR, NOT), where there are one or more children condition and 'leaf' conditions, where there are only operands.
GdaQueryCondition * gda_query_condition_new (GdaQuery *query
,GdaQueryConditionType type
);
Creates a new GdaQueryCondition object
GdaQueryCondition * gda_query_condition_new_copy (GdaQueryCondition *orig
,GHashTable *replacements
);
This is a copy constructor
orig |
a GdaQueryCondition to copy |
|
replacements |
a hash table to store replacements, or |
GdaQueryCondition * gda_query_condition_new_from_sql (GdaQuery *query
,const gchar *sql_cond
,GSList **targets
,GError **error
);
Creates a new GdaQueryCondition object, which references other objects of query
,
from the sql_cond
statement.
void gda_query_condition_set_cond_type (GdaQueryCondition *condition
,GdaQueryConditionType type
);
Sets the kind of condition condition
represents. If type
implies a node condition and
condition
currently represents a leaf, or if type
implies a leaf condition and
condition
currently represents a node, then condition
is changed without any error.
GdaQueryConditionType
gda_query_condition_get_cond_type (GdaQueryCondition *condition
);
Get the type of condition
GSList *
gda_query_condition_get_children (GdaQueryCondition *condition
);
Get a list of GdaQueryCondition objects which are children of condition
GdaQueryCondition *
gda_query_condition_get_parent (GdaQueryCondition *condition
);
Get the GdaQueryCondition object which is parent of condition
GdaQueryCondition * gda_query_condition_get_child_by_xml_id (GdaQueryCondition *condition
,const gchar *xml_id
);
Get a pointer to a GdaQueryCondition child from its XML Id
condition |
a GdaQueryCondition object |
|
xml_id |
the XML Id of the requested GdaQueryCondition child |
gboolean gda_query_condition_is_ancestor (GdaQueryCondition *condition
,GdaQueryCondition *ancestor
);
Tests if ancestor
is an ancestor of condition
gboolean
gda_query_condition_is_leaf (GdaQueryCondition *condition
);
Tells if condition
is a leaf condition (not AND, OR, NOT, etc)
gboolean gda_query_condition_node_add_child (GdaQueryCondition *condition
,GdaQueryCondition *child
,GError **error
);
Adds a child to condition
; this is possible only if condition
is a node type (AND, OR, etc)
condition |
a GdaQueryCondition object |
|
child |
a GdaQueryCondition object |
|
error |
location to store error, or |
void gda_query_condition_node_del_child (GdaQueryCondition *condition
,GdaQueryCondition *child
);
Removes a child from condition
; this is possible only if condition
is a node type (AND, OR, etc)
void gda_query_condition_leaf_set_operator (GdaQueryCondition *condition
,GdaQueryConditionOperator op
,GdaQueryField *field
);
GdaQueryField * gda_query_condition_leaf_get_operator (GdaQueryCondition *condition
,GdaQueryConditionOperator op
);
Get one of condition
's operators.
gboolean gda_query_condition_represents_join (GdaQueryCondition *condition
,GdaQueryTarget **target1
,GdaQueryTarget **target2
,gboolean *is_equi_join
);
Tells if condition
represents a join condition: it is a condition (within a GdaQuery object)
for which the only GdaQueryFieldField fields taking part in the condition are from two distincts
GdaQueryTarget objects. Such conditions can be assigned to a GdaQueryJoin object using the
gda_query_join_set_condition()
or gda_query_join_set_condition_from_fkcons()
methods.
Additionnaly, if condition
is a join condition, and if target1
and target2
are not NULL
then they are set to point to the two GdaQueryTarget objects taking part in the condition. In this
case target1
and target2
wil hold non NULL
values.
In a similar way, if is_equi_join
is not NULL
, then it will be set to TRUE if the join
condition is an equi join (that is the only comparison operator is the equal sign and there are
only AND operators in the condition).
If condition
is not a join condition, then target1
, target2
and is_equi_join
are left
untouched.
condition |
a GdaQueryCondition object |
|
target1 |
place to store one of the targets, or |
|
target2 |
place to store the other target, or |
|
is_equi_join |
place to store if the join is an equi join |
gboolean gda_query_condition_represents_join_strict (GdaQueryCondition *condition
,GdaQueryTarget **target1
,GdaQueryTarget **target2
);
Tells if condition
represents a strict join condition: it is a join condition as defined for the
gda_query_condition_represents_join()
method, but where the condition is either "target1.field1=target2.field2"
or a list of such conditions conjuncted by the AND operator.
If condition
is not a join condition, then target1
and target2
are left
untouched.
condition |
a GdaQueryCondition object |
|
target1 |
place to store one of the targets, or |
|
target2 |
place to store the other target, or |
GSList *
gda_query_condition_get_main_conditions
(GdaQueryCondition *condition
);
Makes a list of all the conditions which
are always verified by condition
when it returns TRUE when evaluated.
Basically the returned list lists the atomic conditions which are AND'ed
together to form the complex condition
.
Examples: if condition
is:
"A and B" then the list will contains {A, B}
"A and (B or C)" it will contain {A, B or C}
"A and (B and not C)", it will contain {A, B, not C}
GSList *
gda_query_condition_get_ref_objects_all
(GdaQueryCondition *cond
);
Get a complete list of the objects referenced by cond
,
including its descendants (unlike the gda_referer_get_ref_objects()
function applied to cond
).