Open cpwright opened 3 years ago
There is a hidden risk in this - any case in the new switch constructs can be composed of not just an expression, as in the example, but a yield statement or a block ending in a yield statement. Right now that would fail in our parser, as we only allow a subset of java expressions (no class declarations, etc). Making it a language feature could also let a user offer type unions for a column instead of just "find the most specific type that allows Double, String, SmartKey" etc...
I can't see an obvious reason that it would be necessarily unsafe for grpc calls, but our existing protections also make the explicit assumption that only certain expressions (unary, binary, method call) can appear, no statements.
--
With that said, this could be excellent for filters too, and we might even want to expose the experimental/preview pattern match feature as well?
As a developer, I want to use switch expressions inside of DB language (update) clauses. The current method of doing this involves many layers of nested ternary operators, which is difficult to read and error prone. For example:
Could better be represented as: