changeset 21912:7a87ed7c9f88

dict-sql: Fix setting $variables to iteration key when map had multiple values
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 07 Apr 2017 12:42:12 +0300
parents abfa9d470305
children 4c81a48916cb
files src/lib-dict/dict-sql.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict-sql.c	Fri Apr 07 09:14:27 2017 +0300
+++ b/src/lib-dict/dict-sql.c	Fri Apr 07 12:42:12 2017 +0300
@@ -757,7 +757,8 @@
 		str_append_c(ctx->key, '/');
 
 	count = sql_result_get_fields_count(ctx->result);
-	i = (ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0 ? 0 : 1;
+	i = (ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0 ? 0 :
+		ctx->map->values_count;
 	sql_field_i = ctx->sql_fields_start_idx;
 	for (p = ctx->map->pattern + ctx->pattern_prefix_len; *p != '\0'; p++) {
 		if (*p != '$')