GdaQueryJoin

GdaQueryJoin — Represents a join between two different entities

Functions

Properties

GdaQuery * query Read / Write / Construct Only
GdaQueryTarget * target1 Read / Write
gchar * target1-id Write
GdaQueryTarget * target2 Read / Write
gchar * target2-id Write

Signals

void condition-changed Run First
void type-changed Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GdaObject
        ╰── GdaQueryObject
            ╰── GdaQueryJoin

Implemented Interfaces

GdaQueryJoin implements GdaXmlStorage and GdaReferer.

Description

This object is a join, within a SELECT query, between two different entities participating in the query; the entoties are themselves represented by GdaQueryTarget objects. It is important to specify joinning conditions as joins and not simply as WHERE conditions because the joins carry more information than a simple condition and because some features of Libmergeant rely on the joins analysis.

It implements the GdaXmlStorage and GdaReferer interfaces.

Functions

gda_query_join_new_with_targets ()

GdaQueryJoin *
gda_query_join_new_with_targets (GdaQuery *query,
                                 GdaQueryTarget *target_1,
                                 GdaQueryTarget *target_2);

Creates a new GdaQueryJoin object. Note: the GdaQueryTarget ranks (1st and 2nd) does not matter, but is necessary since the join may not be symetrical (LEFT or RIGHT join). Also, the GdaQueryJoin object may decide to swap the two if necessary.

Parameters

query

a GdaQuery object in which the join will occur

 

target_1

the 1st GdaQueryTarget object participating in the join

 

target_2

the 2nd GdaQueryTarget object participating in the join

 

Returns

the new object


gda_query_join_new_with_xml_ids ()

GdaQueryJoin *
gda_query_join_new_with_xml_ids (GdaQuery *query,
                                 const gchar *target_1_xml_id,
                                 const gchar *target_2_xml_id);

Creates a new GdaQueryJoin object. Note: the GdaQueryTarget ranks (1st and 2nd) does not matter, but is necessary since the join may not be symetrical (LEFT or RIGHT join). Also, the GdaQueryJoin object may decide to swap the two if necessary.

Parameters

query

a GdaQuery object in which the join will occur

 

target_1_xml_id

the 1st GdaQueryTarget object's XML id participating in the join

 

target_2_xml_id

the 2nd GdaQueryTarget object's XML id participating in the join

 

Returns

the new object


gda_query_join_new_copy ()

GdaQueryJoin *
gda_query_join_new_copy (GdaQueryJoin *orig,
                         GHashTable *replacements);

Copy constructor

Parameters

orig

a GdaQueryJoin to make a copy of

 

replacements

a hash table to store replacements, or NULL

 

Returns

a the new copy of orig


gda_query_join_set_join_type ()

void
gda_query_join_set_join_type (GdaQueryJoin *join,
                              GdaQueryJoinType type);

Sets the type of join

Parameters

join

a GdaQueryJoin object

 

type

the new type of join

 

gda_query_join_get_join_type ()

GdaQueryJoinType
gda_query_join_get_join_type (GdaQueryJoin *join);

Get the type of a join

Parameters

join

a GdaQueryJoin object

 

Returns

the type of join


gda_query_join_get_query ()

GdaQuery *
gda_query_join_get_query (GdaQueryJoin *join);

Get the GdaQuery to which join is attached to

Parameters

join

a GdaQueryJoin object

 

Returns

the GdaQuery


gda_query_join_get_target_1 ()

GdaQueryTarget *
gda_query_join_get_target_1 (GdaQueryJoin *join);

Get the 1st GdaQueryTarget participating in the join

Parameters

join

a GdaQueryJoin object

 

Returns

the GdaQueryTarget


gda_query_join_get_target_2 ()

GdaQueryTarget *
gda_query_join_get_target_2 (GdaQueryJoin *join);

Get the 2nd GdaQueryTarget participating in the join

Parameters

join

a GdaQueryJoin object

 

Returns

the GdaQueryTarget


gda_query_join_swap_targets ()

void
gda_query_join_swap_targets (GdaQueryJoin *join);

Changes the relative roles of the two GdaQueryTarget objects. It does not change the join condition itself, and is usefull only for the internals of the GdaQuery object

Parameters

join

a GdaQueryJoin object

 

gda_query_join_set_condition_from_fkcons ()

gboolean
gda_query_join_set_condition_from_fkcons
                               (GdaQueryJoin *join);

Creates a GdaQueryCondition for join using the foreign key constraints present in the database if the two targets join joins are database tables (GdaDictTable objects).

If there is more than one FK constraint between the database tables, then no join is created, and the call returns FALSE.

Parameters

join

a GdaQueryJoin object

 

Returns

TRUE if suitable foreign keys were found and a join condition has been created


gda_query_join_set_condition_from_sql ()

gboolean
gda_query_join_set_condition_from_sql (GdaQueryJoin *join,
                                       const gchar *cond,
                                       GError **error);

Parses cond and if it represents a valid SQL expression to be join 's condition, then set it to be join 's condition.

Parameters

join

a GdaQueryJoin object

 

cond

a SQL expression

 

error

place to store the error, or NULL

 

Returns

a TRUE on success


gda_query_join_set_condition ()

gboolean
gda_query_join_set_condition (GdaQueryJoin *join,
                              GdaQueryCondition *cond);

Sets cond to be join 's condition. This is possible only if cond uses query fields which are either of type GdaQueryFieldField and reference one of the two targets which join uses, or any other query field type.

Parameters

join

a GdaQueryJoin object

 

cond

a GdaQueryCondition object, or NULL to remove the join's condition

 

Returns

TRUE if no error occurred


gda_query_join_get_condition ()

GdaQueryCondition *
gda_query_join_get_condition (GdaQueryJoin *join);

Get the join's associated condition

Parameters

join

a GdaQueryJoin object

 

Returns

the GdaQueryCondition object


gda_query_join_render_type ()

const gchar *
gda_query_join_render_type (GdaQueryJoin *join);

Get the SQL version of the join type ("INNER JOIN", "LEFT JOIN", etc)

Parameters

join

a GdaQueryJoin object

 

Returns

the type as a const string

Types and Values

GdaQueryJoin

typedef struct _GdaQueryJoin GdaQueryJoin;


enum GdaQueryJoinType

Members

GDA_QUERY_JOIN_TYPE_INNER

   

GDA_QUERY_JOIN_TYPE_LEFT_OUTER

   

GDA_QUERY_JOIN_TYPE_RIGHT_OUTER

   

GDA_QUERY_JOIN_TYPE_FULL_OUTER

   

GDA_QUERY_JOIN_TYPE_CROSS

   

GDA_QUERY_JOIN_TYPE_LAST

   

Property Details

The “query” property

  “query”                    GdaQuery *

Flags: Read / Write / Construct Only


The “target1” property

  “target1”                  GdaQueryTarget *

Flags: Read / Write


The “target1-id” property

  “target1-id”               gchar *

Flags: Write

Default value: NULL


The “target2” property

  “target2”                  GdaQueryTarget *

Flags: Read / Write


The “target2-id” property

  “target2-id”               gchar *

Flags: Write

Default value: NULL

Signal Details

The “condition-changed” signal

void
user_function (GdaQueryJoin *gdaqueryjoin,
               gpointer      user_data)

Parameters

dbjoin

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “type-changed” signal

void
user_function (GdaQueryJoin *gdaqueryjoin,
               gpointer      user_data)

Parameters

dbjoin

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First