[glom] UsesRelationship: Correct use of SqlBuilder for related relationships.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] UsesRelationship: Correct use of SqlBuilder for related relationships.
- Date: Mon, 24 May 2010 21:30:14 +0000 (UTC)
commit f49825163760c806263fa3bf1298c78ce24465d5
Author: Murray Cumming <murrayc murrayc com>
Date: Mon May 24 23:29:38 2010 +0200
UsesRelationship: Correct use of SqlBuilder for related relationships.
* glom/libglom/data_structure/layout/usesrelationship.cc:
add_sql_join_alias_definition(): Correct the join definition for
related relationships.
ChangeLog | 8 ++++++++
.../data_structure/layout/usesrelationship.cc | 19 +++++++++++--------
2 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eaff01a..a635ed6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-05-24 Murray Cumming <murrayc murrayc com>
+
+ UsesRelationship: Correct use of SqlBuilder for related relationships.
+
+ * glom/libglom/data_structure/layout/usesrelationship.cc:
+ add_sql_join_alias_definition(): Correct the join definition for
+ related relationships.
+
2010-05-21 Murray Cumming <murrayc murrayc com>
UsesRelationship: Use SqlBuilder::select_add_target() with the join.
diff --git a/glom/libglom/data_structure/layout/usesrelationship.cc b/glom/libglom/data_structure/layout/usesrelationship.cc
index 71cfd88..b8569d0 100644
--- a/glom/libglom/data_structure/layout/usesrelationship.cc
+++ b/glom/libglom/data_structure/layout/usesrelationship.cc
@@ -222,11 +222,12 @@ void UsesRelationship::add_sql_join_alias_definition(const Glib::RefPtr<Gnome::G
{
// Specify an alias, to avoid ambiguity when using 2 relationships to the same table.
const Glib::ustring alias_name = get_sql_join_alias_name();
- const guint to_target_id = builder->select_add_target(m_relationship->get_to_table(), alias_name);
// Add the JOIN:
if(!get_has_related_relationship_name())
{
+ const guint to_target_id = builder->select_add_target(m_relationship->get_to_table(), alias_name);
+
builder->select_join_targets(
builder->select_add_target(m_relationship->get_from_table()),
to_target_id,
@@ -241,14 +242,16 @@ void UsesRelationship::add_sql_join_alias_definition(const Glib::RefPtr<Gnome::G
UsesRelationship parent_relationship;
parent_relationship.set_relationship(m_relationship);
+ const guint to_target_id = builder->select_add_target(m_related_relationship->get_to_table(), alias_name);
+
builder->select_join_targets(
- builder->select_add_target(m_relationship->get_from_table()), //TODO: Must we use the ID from select_add_target_id()?
- to_target_id,
- Gnome::Gda::SQL_SELECT_JOIN_LEFT,
- builder->add_cond(
- Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
- builder->add_id("\"" + parent_relationship.get_sql_join_alias_name() + "\".\"" + m_related_relationship->get_from_field() + "\""),
- builder->add_id("\"" + alias_name + "\".\"" + m_relationship->get_to_field() + "\"") ) );
+ builder->select_add_target(m_relationship->get_from_table()), //TODO: Must we use the ID from select_add_target_id()?
+ to_target_id,
+ Gnome::Gda::SQL_SELECT_JOIN_LEFT,
+ builder->add_cond(
+ Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id("\"" + parent_relationship.get_sql_join_alias_name() + "\".\"" + m_related_relationship->get_from_field() + "\""),
+ builder->add_id("\"" + alias_name + "\".\"" + m_related_relationship->get_to_field() + "\"") ) );
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]