From 6966222e92415ba71a5af29629fd5963c698af84 Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Wed, 7 Oct 2026 10:02:19 +0200 Subject: [PATCH 1/2] Improve dict export --- CHANGELOG.md | 4 ++++ inc/ti/dict.h | 2 +- inc/ti/version.h | 4 ++-- itest/test_advanced.py | 10 ++++++++-- src/ti/export.c | 16 +++++++++------- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7336c85..ae3b880c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.10.1-alpha0 + +* Improve `dict` export, pr # + # v1.10.0 * Fixed sanatize runtime checking, pr #455. diff --git a/inc/ti/dict.h b/inc/ti/dict.h index cbda8e460..666bf5df7 100644 --- a/inc/ti/dict.h +++ b/inc/ti/dict.h @@ -13,9 +13,9 @@ typedef enum { + TI_DICT_KEY_UUID, TI_DICT_KEY_INT, TI_DICT_KEY_STR, - TI_DICT_KEY_UUID, } ti_dict_enum_e; typedef struct diff --git a/inc/ti/version.h b/inc/ti/version.h index 2f38ca18d..15ff029dd 100644 --- a/inc/ti/version.h +++ b/inc/ti/version.h @@ -6,7 +6,7 @@ #define TI_VERSION_MAJOR 1 #define TI_VERSION_MINOR 10 -#define TI_VERSION_PATCH 0 +#define TI_VERSION_PATCH 1 /* The syntax version is used to test compatibility with functions * using the `ti_nodes_check_syntax()` function */ @@ -25,7 +25,7 @@ * "-rc0" * "" */ -#define TI_VERSION_PRE_RELEASE "" +#define TI_VERSION_PRE_RELEASE "-alpha0" #define TI_MAINTAINER \ "Jeroen van der Heijden " diff --git a/itest/test_advanced.py b/itest/test_advanced.py index 55a1df709..7cd76ce7e 100755 --- a/itest/test_advanced.py +++ b/itest/test_advanced.py @@ -1571,7 +1571,8 @@ async def test_assign_in_def(self, client): self.assertEqual(res, '|| x[0] += 1') # formatted closure async def test_export(self, client): - script = r''' + self.maxDiff = 1800 + script = r""" try(commit('Source: collection `stuff`')); new_type('Friend'); @@ -1652,6 +1653,11 @@ async def test_export(self, client): c: |a, b| a + b, float: 3.140000, u: uuid('01a08b43-4abd-7529-82a2-9ae352b2f10f'), + d: dict([ + [uuid('01a08b43-4abd-7529-82a2-9ae352b2f10f'), 0], + [0, 1], + ['a', 2], + ]), }); @@ -1665,7 +1671,7 @@ async def test_export(self, client): .to_type('Root'); 'DONE'; -'''.lstrip().replace(' ', '\t') +""".lstrip().replace(' ', '\t') await client.query(script) res = await client.query('export();') self.assertEqual(res, script) diff --git a/src/ti/export.c b/src/ti/export.c index 633400e57..8515e4ac7 100644 --- a/src/ti/export.c +++ b/src/ti/export.c @@ -396,18 +396,20 @@ static int export__dict_pair(ti_dict_key_t * key, switch(key->tp) { - case TI_DICT_KEY_INT: - if (buf_append_fmt(buf, "%"PRIi64", ", key->via.id)) - return -1; - break; case TI_DICT_KEY_UUID: if (export__uuid(fmt, key->via.uuid) || - buf_write(buf, ',')) + buf_write(buf, ',') || + buf_write(buf, ' ')) + return -1; + break; + case TI_DICT_KEY_INT: + if (buf_append_fmt(buf, "%"PRIi64", ", key->via.id)) return -1; break; case TI_DICT_KEY_STR: if (ti_fmt_strn(fmt, key->via.str.str, key->via.str.n) || - buf_write(buf, ',')) + buf_write(buf, ',') || + buf_write(buf, ' ')) return -1; break; } @@ -501,7 +503,7 @@ static int export__val(ti_fmt_t * fmt, ti_val_t * val) fmt->indent--; return -( ti_fmt_indent(fmt) || - buf_append_str(buf, "])\n") + buf_append_str(buf, "])") ); } case TI_VAL_ERROR: From fdc629358121348c60b693db4cc26a4db34e1319 Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Wed, 7 Oct 2026 10:17:58 +0200 Subject: [PATCH 2/2] typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3b880c7..ba66c8778 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # v1.10.1-alpha0 -* Improve `dict` export, pr # +* Improved `dict` export _(cosmetic)_, pr #462. # v1.10.0