[libgda: 1/2] DDL: bug in fkey parsing is fixed
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 1/2] DDL: bug in fkey parsing is fixed
- Date: Thu, 20 Sep 2018 02:37:19 +0000 (UTC)
commit 95f3036570f14568d29e60143fdfd4769048b4f3
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Tue Sep 18 14:27:23 2018 -0500
DDL: bug in fkey parsing is fixed
DTD schema was modified to reflect optional character of some element.
fkey node parsing algorithm had a bug. This patch fixes this bug.
libgda/gda-ddl-fkey.c | 36 ++++++++++++++++++++----------------
libgda/libgda-ddl-creator.dtd | 2 +-
tests/ddl/check-ddl-fkey.c | 2 +-
tests/ddl/meson.build | 22 ++++++++++++++++++++++
4 files changed, 44 insertions(+), 18 deletions(-)
---
diff --git a/libgda/gda-ddl-fkey.c b/libgda/gda-ddl-fkey.c
index d1732afe8..a618e476f 100644
--- a/libgda/gda-ddl-fkey.c
+++ b/libgda/gda-ddl-fkey.c
@@ -261,31 +261,35 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
prop = xmlGetProp (node,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_ONUPDATE]);
- g_assert(prop);
+ if (prop)
+ {
+ priv->m_onupdate = GDA_DDL_FKEY_NO_ACTION;
- priv->m_onupdate = GDA_DDL_FKEY_NO_ACTION;
+ for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
+ {
+ if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
+ priv->m_onupdate = (GdaDdlFkeyReferenceAction)i;
+ }
- for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
- {
- if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
- priv->m_onupdate = (GdaDdlFkeyReferenceAction)i;
+ xmlFree (prop);
+ prop = NULL;
}
- xmlFree (prop);
- prop = NULL;
prop = xmlGetProp (node,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_ONDELETE]);
- g_assert(prop);
-
- for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
+ if (prop)
{
- if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
- priv->m_ondelete = (GdaDdlFkeyReferenceAction)i;
- }
+ for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
+ {
+ if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
+ priv->m_ondelete = (GdaDdlFkeyReferenceAction)i;
+ }
- xmlFree (prop);
- prop = NULL;
+ xmlFree (prop);
+ prop = NULL;
+
+ }
name = NULL;
xmlChar *reffield = NULL;
diff --git a/libgda/libgda-ddl-creator.dtd b/libgda/libgda-ddl-creator.dtd
index 1341b952f..9954797f3 100644
--- a/libgda/libgda-ddl-creator.dtd
+++ b/libgda/libgda-ddl-creator.dtd
@@ -27,7 +27,7 @@
<!ELEMENT check (#PCDATA)>
-<!ELEMENT fkey (fk_field?)>
+<!ELEMENT fkey (fk_field+)>
<!ATTLIST fkey reftable CDATA #IMPLIED>
<!ATTLIST fkey onupdate (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
<!ATTLIST fkey ondelete (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
diff --git a/tests/ddl/check-ddl-fkey.c b/tests/ddl/check-ddl-fkey.c
index 3372832b7..221cc76fd 100644
--- a/tests/ddl/check-ddl-fkey.c
+++ b/tests/ddl/check-ddl-fkey.c
@@ -181,7 +181,7 @@ test_ddl_fkey_finish (CheckDdlObject *self,
gconstpointer user_data)
{
g_free (self->xmlfile);
- gda_ddl_fkey_free (self->fkey);
+ g_object_unref (self->fkey);
xmlFreeDoc (self->doc);
g_list_free (self->reffield);
g_list_free (self->fkfield);
diff --git a/tests/ddl/meson.build b/tests/ddl/meson.build
index fe4643bcd..7dce8932c 100644
--- a/tests/ddl/meson.build
+++ b/tests/ddl/meson.build
@@ -98,3 +98,25 @@ test('ddlview', ddltv,
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
+ddlfkey = executable('check_ddl_fkey',
+ 'check-ddl-fkey.c',
+ c_args: [
+ '-include',
+ meson.build_root() + '/config.h',
+ '-DCHECK_FILES="'+meson.source_root()+'"',
+ '-DTOP_BUILD_DIR="'+meson.build_root()+'"'
+ ],
+ link_with: libgda,
+ dependencies: [
+ libgda_dep,
+ inc_rooth_dep,
+ inc_sqliteh_dep
+ ],
+ install: false
+ )
+test('ddlfkey', ddlfkey,
+ env: [
+ 'GDA_TOP_SRC_DIR='+meson.source_root(),
+ 'GDA_TOP_BUILD_DIR='+meson.build_root()
+ ]
+ )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]