[libgda: 1/2] Bug in GdaDdlFkey implementation.



commit 6ccc1d091477b6238c8721ab9c4c150c66c0abca
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Mon Sep 24 22:02:27 2018 -0500

    Bug in GdaDdlFkey implementation.
    
    Wrong interpretation of /FKEY_S node. It should be treated as a
    sequence.

 libgda/gda-ddl-fkey.c  | 15 ++++++++-------
 libgda/gda-ddl-fkey.h  |  1 +
 libgda/gda-ddl-table.c |  3 ++-
 3 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/libgda/gda-ddl-fkey.c b/libgda/gda-ddl-fkey.c
index a618e476f..a3c41e9af 100644
--- a/libgda/gda-ddl-fkey.c
+++ b/libgda/gda-ddl-fkey.c
@@ -610,6 +610,7 @@ gda_ddl_fkey_set_field (GdaDdlFkey  *self,
 gboolean
 gda_ddl_fkey_prepare_create  (GdaDdlFkey *self,
                               GdaServerOperation *op,
+                              gint i,
                               GError **error)
 {
   GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
@@ -617,19 +618,19 @@ gda_ddl_fkey_prepare_create  (GdaDdlFkey *self,
   if (!gda_server_operation_set_value_at(op,
                                          priv->mp_ref_table,
                                          error,
-                                         "/FKEY_S/FKEY_REF_TABLE"))
+                                         "/FKEY_S/%d/FKEY_REF_TABLE",i))
     return FALSE;
 
   if (!gda_server_operation_set_value_at(op,
                                          OnAction[priv->m_ondelete],
                                          error,
-                                         "/FKEY_S/FKEY_ONDELETE"))
+                                         "/FKEY_S/%d/FKEY_ONDELETE",i))
     return FALSE;
 
   if (!gda_server_operation_set_value_at(op,
                                          OnAction[priv->m_onupdate],
                                          error,
-                                         "/FKEY_S/FKEY_ONUPDATE"))
+                                         "/FKEY_S/%d/FKEY_ONUPDATE",i))
     return FALSE;
 
   GList *itfield = NULL;
@@ -644,15 +645,15 @@ gda_ddl_fkey_prepare_create  (GdaDdlFkey *self,
       if (!gda_server_operation_set_value_at(op,
                                              itfield->data,
                                              error,
-                                             "/FKEY_S/FKEY_FIELDS_A/@FK_FIELD/%d",
-                                             fkeycount))
+                                             "/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d",
+                                             i,fkeycount))
         return FALSE;
 
       if (!gda_server_operation_set_value_at(op,
                                              itreffield->data,
                                              error,
-                                             "/FKEY_S/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d",
-                                             fkeycount))
+                                             "/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d",
+                                             i,fkeycount))
         return FALSE;
 
       fkeycount++;
diff --git a/libgda/gda-ddl-fkey.h b/libgda/gda-ddl-fkey.h
index 2c7678e8f..c5ed0c086 100644
--- a/libgda/gda-ddl-fkey.h
+++ b/libgda/gda-ddl-fkey.h
@@ -89,6 +89,7 @@ void              gda_ddl_fkey_set_onupdate    (GdaDdlFkey *self,
 
 gboolean          gda_ddl_fkey_prepare_create  (GdaDdlFkey *self,
                                                 GdaServerOperation *op,
+                                                gint i,
                                                 GError **error);
 GdaDdlFkey       *gda_ddl_fkey_new_from_meta   (GdaMetaTableForeignKey *metafkey);
 
diff --git a/libgda/gda-ddl-table.c b/libgda/gda-ddl-table.c
index 407854571..6065136a9 100644
--- a/libgda/gda-ddl-table.c
+++ b/libgda/gda-ddl-table.c
@@ -521,8 +521,9 @@ gda_ddl_table_prepare_create (GdaDdlTable *self,
     if(!gda_ddl_column_prepare_create (GDA_DDL_COLUMN(it->data),op,i++,error))
       return FALSE;
 
+  i = 0;
   for (it = priv->mp_fkeys;it;it=it->next)
-    if(!gda_ddl_fkey_prepare_create (it->data,op,error))
+    if(!gda_ddl_fkey_prepare_create (GDA_DDL_FKEY(it->data),op,i++,error))
       return FALSE;
 
   return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]