Open matthew-wozniczka opened 7 years ago
Actually, thinking about it further, variant/dynamic columns/fields need to be casted to an array type before doing the array element reference(right?), so that should resolve that ambiguity (though it may still be hard to implement due to it affecting parsing).
Yes; I would expect that an array/dynamic column would need to be cast to an array type before doing the element dereferencing. Is the issue for parsers that they may not understand how to interpret the brackets without knowing the type of the column (i.e., whether or not it is collection-valued)? From an ANSI standpoint, the brackets would always reference an element of the array, we're just trying to account for existing implementation syntax that use this as a shortcut for aliasing.
Yes, the parser (probably) won't know the type of the column, so it can't make a decision on how to interpret the brackets.
The only way it could comply with the spec (without a large change to the impl. to leave the disambiguation to a later stage of processing) is to assume it's always an array element reference, which would change the semantics of existing queries.
Section 3.11.2.1 (Array Element Reference) states
Just to be clear, this only applies to column/field references which refer to a fixed, non-SQL_VARIANT column, correct?