[libgda/LIBGDA_5.2] Time/Date/Timestamp: return NULL string if no set
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_5.2] Time/Date/Timestamp: return NULL string if no set
- Date: Mon, 22 Apr 2019 22:45:57 +0000 (UTC)
commit d308f5bad9db134f0f8b68662bf5ec9601f2b7ee
Author: Daniel Espinosa <esodan gmail com>
Date: Mon Apr 22 17:44:03 2019 -0500
Time/Date/Timestamp: return NULL string if no set
NEWS | 1 +
libgda/gda-value.c | 15 ++++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index eab8243c3..41bc53dff 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ libgda 5.2.9
- Fix Sun JRE 1.8 detection
- Drop unneeded JAVAH variable check
- Fix build for System Installed SQLite libs
+ - Non-Dates and Timestamps values returns 'NULL' string when converted
libgda 5.2.8 2018-12-03
- Fix a typo on sv translation
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 795a11ef4..7ad7dcfad 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -727,7 +727,7 @@ numeric_to_string (const GValue *src, GValue *dest)
if (numeric)
g_value_set_string (dest, numeric->number);
else
- g_value_set_string (dest, "0.0");
+ g_value_set_string (dest, "NULL");
}
static void
@@ -1080,7 +1080,7 @@ time_to_string (const GValue *src, GValue *dest)
g_string_free (string, FALSE);
}
else
- g_value_set_string (dest, "00:00:00");
+ g_value_set_string (dest, "NULL");
}
/* Transform a String GValue to a GdaTime from a string like "12:30:15+01" */
@@ -2341,8 +2341,13 @@ gda_value_stringify (const GValue *value)
g_ascii_formatd (buffer, sizeof (buffer), "%f", g_value_get_double (value));
return g_strdup (buffer);
}
- else if (type == GDA_TYPE_NUMERIC)
- return gda_numeric_get_string (gda_value_get_numeric (value));
+ else if (type == GDA_TYPE_NUMERIC) {
+ gchar *str = gda_numeric_get_string (gda_value_get_numeric (value));
+ if (str == NULL) {
+ str = g_strdup ("NULL");
+ }
+ return str;
+ }
else if (type == G_TYPE_DATE) {
GDate *date;
date = (GDate *) g_value_get_boxed (value);
@@ -2357,7 +2362,7 @@ gda_value_stringify (const GValue *value)
date->year, date->month, date->day);
}
else
- return g_strdup ("0000-00-00");
+ return g_strdup ("NULL");
}
else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING)) {
GValue *string;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]