diff --git a/modules/csvparser/filterx-func-format-csv.c b/modules/csvparser/filterx-func-format-csv.c index 5bb496a531..6af0abb3a2 100644 --- a/modules/csvparser/filterx-func-format-csv.c +++ b/modules/csvparser/filterx-func-format-csv.c @@ -235,7 +235,7 @@ filterx_function_format_csv_new(const gchar *function_name, FilterXFunctionArgs self->super.super.eval = _eval; self->super.super.free_fn = _free; - self->delimiter = ' '; + self->delimiter = ','; if (!_extract_arguments(self, args, error)) goto error; diff --git a/modules/csvparser/filterx-func-parse-csv.c b/modules/csvparser/filterx-func-parse-csv.c index e329760efb..d1593026f7 100644 --- a/modules/csvparser/filterx-func-parse-csv.c +++ b/modules/csvparser/filterx-func-parse-csv.c @@ -326,7 +326,7 @@ filterx_function_parse_csv_new(const gchar *function_name, FilterXFunctionArgs * filterx_function_init_instance(&self->super, function_name); self->super.super.eval = _eval; self->super.super.free_fn = _free; - csv_scanner_options_set_delimiters(&self->options, " "); + csv_scanner_options_set_delimiters(&self->options, ","); csv_scanner_options_set_quote_pairs(&self->options, "\"\"''"); csv_scanner_options_set_flags(&self->options, CSV_SCANNER_STRIP_WHITESPACE); csv_scanner_options_set_dialect(&self->options, CSV_SCANNER_ESCAPE_NONE); diff --git a/modules/csvparser/tests/test_filterx_func_format_csv.c b/modules/csvparser/tests/test_filterx_func_format_csv.c index e7490a19c9..1a25b0d6b4 100644 --- a/modules/csvparser/tests/test_filterx_func_format_csv.c +++ b/modules/csvparser/tests/test_filterx_func_format_csv.c @@ -102,7 +102,7 @@ Test(filterx_func_format_csv, test_array_mode_with_default_delimiter) GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, csv_data)); - _assert_format_csv(args, "foo bar baz"); + _assert_format_csv(args, "foo,bar,baz"); } Test(filterx_func_format_csv, test_array_mode_with_custom_delimiter) @@ -124,7 +124,7 @@ Test(filterx_func_format_csv, test_array_mode_skip_column_names) args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_FORMAT_CSV_ARG_NAME_COLUMNS, filterx_non_literal_new(filterx_json_array_new_from_repr("[\"col1\",\"col2\"]", -1)))); - _assert_format_csv(args, "foo bar baz"); + _assert_format_csv(args, "foo,bar,baz"); } Test(filterx_func_format_csv, test_dict_mode_without_column_names_with_default_delimiter) @@ -134,7 +134,7 @@ Test(filterx_func_format_csv, test_dict_mode_without_column_names_with_default_d GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, csv_data)); - _assert_format_csv(args, "foo bar baz"); + _assert_format_csv(args, "foo,bar,baz"); } Test(filterx_func_format_csv, test_dict_mode_without_column_names_with_custom_delimiter) @@ -158,7 +158,7 @@ Test(filterx_func_format_csv, test_dict_mode_with_column_names_with_default_deli args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_FORMAT_CSV_ARG_NAME_COLUMNS, filterx_non_literal_new(filterx_json_array_new_from_repr("[\"col2\",\"col1\"]", -1)))); - _assert_format_csv(args, "bar foo"); + _assert_format_csv(args, "bar,foo"); } Test(filterx_func_format_csv, test_dict_mode_with_column_names_with_custom_delimiter) diff --git a/modules/csvparser/tests/test_filterx_func_parse_csv.c b/modules/csvparser/tests/test_filterx_func_parse_csv.c index 6f11245b4d..a54e9d46c9 100644 --- a/modules/csvparser/tests/test_filterx_func_parse_csv.c +++ b/modules/csvparser/tests/test_filterx_func_parse_csv.c @@ -113,7 +113,7 @@ Test(filterx_func_parse_csv, test_skipped_opts_causes_default_behaviour) { GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, - filterx_literal_new(filterx_string_new("foo bar baz tik tak toe", -1)))); + filterx_literal_new(filterx_string_new("foo,bar,baz,tik,tak,toe", -1)))); GError *err = NULL; GError *args_err = NULL; @@ -140,7 +140,7 @@ Test(filterx_func_parse_csv, test_skipped_opts_causes_default_behaviour) Test(filterx_func_parse_csv, test_set_optional_first_argument_column_names) { GList *args = NULL; - args = g_list_append(args, filterx_function_arg_new(NULL, filterx_literal_new(filterx_string_new("foo bar baz", -1)))); + args = g_list_append(args, filterx_function_arg_new(NULL, filterx_literal_new(filterx_string_new("foo,bar,baz", -1)))); FilterXObject *col_names = _generate_column_list("1st", "2nd", "3rd", NULL); args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS, filterx_literal_new(col_names))); @@ -171,7 +171,7 @@ Test(filterx_func_parse_csv, test_column_names_sets_expected_column_size_additio { GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, - filterx_literal_new(filterx_string_new("foo bar baz more columns we did not expect", -1)))); + filterx_literal_new(filterx_string_new("foo,bar,baz,more,columns,we,did,not,expect", -1)))); FilterXObject *col_names = _generate_column_list("1st", "2nd", "3rd", NULL); // sets expected column size 3 args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS, filterx_literal_new(col_names))); @@ -262,7 +262,7 @@ Test(filterx_func_parse_csv, test_optional_argument_flag_greedy) { GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, - filterx_literal_new(filterx_string_new("foo bar baz tik tak toe", -1)))); + filterx_literal_new(filterx_string_new("foo,bar,baz,tik,tak,toe", -1)))); args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS, filterx_literal_new(_generate_column_list("1st", "2nd", "3rd", "rest", NULL)))); // columns @@ -285,7 +285,7 @@ Test(filterx_func_parse_csv, test_optional_argument_flag_greedy) LogMessageValueType lmvt; cr_assert(filterx_object_marshal(obj, repr, &lmvt)); - cr_assert_str_eq(repr->str, "{\"1st\":\"foo\",\"2nd\":\"bar\",\"3rd\":\"baz\",\"rest\":\"tik tak toe\"}"); + cr_assert_str_eq(repr->str, "{\"1st\":\"foo\",\"2nd\":\"bar\",\"3rd\":\"baz\",\"rest\":\"tik,tak,toe\"}"); filterx_expr_unref(func); filterx_object_unref(obj); g_error_free(err); @@ -295,7 +295,7 @@ Test(filterx_func_parse_csv, test_optional_argument_flag_non_greedy) { GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, - filterx_literal_new(filterx_string_new("foo bar baz tik tak toe", -1)))); + filterx_literal_new(filterx_string_new("foo,bar,baz,tik,tak,toe", -1)))); args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS, filterx_literal_new(_generate_column_list("1st", "2nd", "3rd", "rest", NULL)))); // columns