From a18e8e0f6dc38fb7425c3fc1a2c39179c298e906 Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Wed, 20 Mar 2024 09:36:00 -0700 Subject: [PATCH] Change StaticType.AnyOfType's .toString to not perform .flatten() (#1393) --- CHANGELOG.md | 2 ++ .../kotlin/org/partiql/types/StaticType.kt | 19 ++++--------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c61a6ba71..a767879343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Thank you to all who have contributed! ### Added ### Changed +- Change `StaticType.AnyOfType`'s `.toString` to not perform `.flatten()` ### Deprecated @@ -165,6 +166,7 @@ Thank you to all who have contributed! ### Deprecated + ### Fixed - Fixes the CLI hanging on invalid queries. See issue #1230. - Fixes Timestamp Type parsing issue. Previously Timestamp Type would get parsed to a Time type. diff --git a/partiql-types/src/main/kotlin/org/partiql/types/StaticType.kt b/partiql-types/src/main/kotlin/org/partiql/types/StaticType.kt index d2ef1756f8..df77f42f6f 100644 --- a/partiql-types/src/main/kotlin/org/partiql/types/StaticType.kt +++ b/partiql-types/src/main/kotlin/org/partiql/types/StaticType.kt @@ -642,21 +642,10 @@ public data class AnyOfType(val types: Set, override val metas: Map< } } - override fun toString(): String = - when (val flattenedType = flatten()) { - is AnyOfType -> { - val unionedTypes = flattenedType.types - when (unionedTypes.size) { - 0 -> "\$null" - 1 -> unionedTypes.first().toString() - else -> { - val types = unionedTypes.joinToString { it.toString() } - "union($types)" - } - } - } - else -> flattenedType.toString() - } + override fun toString(): String { + val types = types.joinToString { it.toString() } + return "union($types)" + } override val allTypes: List get() = this.types.map { it.flatten() }