diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7336c8..ba66c877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.10.1-alpha0 + +* Improved `dict` export _(cosmetic)_, pr #462. + # v1.10.0 * Fixed sanatize runtime checking, pr #455. diff --git a/inc/ti/dict.h b/inc/ti/dict.h index cbda8e46..666bf5df 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 2f38ca18..15ff029d 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 55a1df70..7cd76ce7 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 633400e5..8515e4ac 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: