Esempio n. 1
0
/**
 * gda_sql_param_spec_take_descr:
 * @pspec: a #GdaSqlParamSpec pointer
 * @value: (transfer full): a G_TYPE_STRING #GValue
 *
 * Sets @pspec's description. @value's ownership is transferred to
 * @pspec (which means @pspec is then responsible for freeing it when no longer needed).
 */
void
gda_sql_param_spec_take_descr (GdaSqlParamSpec *pspec, GValue *value)
{
	if (pspec->descr) {
		g_free (pspec->descr);
		pspec->descr = NULL;
	}
	if (value) {
		pspec->descr = _remove_quotes (g_value_dup_string (value));
		gda_value_free (value);
	}
}
Esempio n. 2
0
/**
 * gda_sql_identifier_prepare_for_compare
 * @str: a quoted string
 *
 * Prepares @str to be compared:
 * <itemizedlist>
 * <listitem><para>if surrounded by double quotes or single quotes, then just remove the quotes</para></listitem>
 * <listitem><para>otherwise convert to lower case</para></listitem>
 * </itemizedlist>
 *
 * The quoted string:
 * <itemizedlist>
 *   <listitem><para>must start and finish with the same single or double quotes character</para></listitem>
 *   <listitem><para>can contain the delimiter character (the single or double quotes) in the string if every instance
 *     of it is preceeded with a backslash character or with the delimiter character itself</para></listitem>
 * </itemizedlist>
 *
 * This function is normally used only by database provider's implementation.
 *
 * WARNING: @str must NOT be a composed identifier (&lt;part1&gt;."&lt;part2&gt;" for example)
 * WARNING: you may have to <code>#include &lt;sql-parser/gda-sql-parser.h&gt;</code>
 * 
 * Returns: @str
 *
 * Since: 5.0
 */
gchar *
gda_sql_identifier_prepare_for_compare (gchar *str)
{
	if (!str)
		return NULL;
	if ((*str == '"') || (*str == '\''))
		return _remove_quotes (str);
	else {
		gchar *ptr;
		for (ptr = str; *ptr; ptr++)
			*ptr = g_ascii_tolower (*ptr);
		return str;
	}
}
Esempio n. 3
0
/**
 * gda_sql_param_spec_take_nullok:
 * @pspec: a #GdaSqlParamSpec pointer
 * @value: (transfer full): a G_TYPE_STRING #GValue. 
 *
 * Sets @pspec's ability of being NULL. @value's ownership is transferred to
 * @pspec (which means @pspec is then responsible for freeing it when no longer needed).
 *
 * If @value's string starts by 't' or 'T' then @pspec will be allowed to be %NULL
 */
void
gda_sql_param_spec_take_nullok (GdaSqlParamSpec *pspec, GValue *value)
{
	pspec->nullok = FALSE;
	if (value) {
		gchar *str = (gchar *) g_value_get_string (value);
		if (str) {
			_remove_quotes (str);
			if ((*str == 't') || (*str == 'T'))
				pspec->nullok = TRUE;
		}
		gda_value_free (value);
	}
}
Esempio n. 4
0
/**
 * gda_sql_param_spec_take_type:
 * @pspec: a #GdaSqlParamSpec pointer
 * @value: (transfer full): a G_TYPE_STRING #GValue
 *
 * Sets @pspec's data type. @value's ownership is transferred to
 * @pspec (which means @pspec is then responsible for freeing it when no longer needed).
 *
 * @value must represent a data type, as understood by gda_g_type_from_string().
 */
void
gda_sql_param_spec_take_type (GdaSqlParamSpec *pspec, GValue *value)
{
	pspec->g_type = GDA_TYPE_NULL;
	if (value) {
		gchar *tmp;
		tmp = _remove_quotes (g_value_dup_string (value));
		gda_value_free (value);

		pspec->g_type = gda_g_type_from_string (tmp);
		g_free (tmp);
		if (pspec->g_type == G_TYPE_INVALID)
			pspec->g_type = GDA_TYPE_NULL;
	}
}