Skip to content

Commit

Permalink
Change StaticType.AnyOfType's .toString to not perform .flatten() (#1393
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alancai98 authored and rchowell committed Apr 2, 2024
1 parent a327b20 commit 34dcab6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Thank you to all who have contributed!
### Added

### Changed
- Change `StaticType.AnyOfType`'s `.toString` to not perform `.flatten()`

### Deprecated

Expand Down Expand Up @@ -198,6 +199,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.
Expand Down
19 changes: 4 additions & 15 deletions partiql-types/src/main/kotlin/org/partiql/types/StaticType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -642,21 +642,10 @@ public data class AnyOfType(val types: Set<StaticType>, 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<StaticType>
get() = this.types.map { it.flatten() }
Expand Down

0 comments on commit 34dcab6

Please sign in to comment.