SqlFormatter GetAliasName inconsitent with AddAlias


Ran into a problem where an extension table mapping insert was calling GetAliasName on SqlFormatter. This worked differently than AddAlias.
I made GetAliasName perform the same Add logic as AddAlias and that cleared up that issue. I suggest making that change in the source.


mattwar wrote Apr 27, 2012 at 4:20 AM

It is expected that all aliases declared within the query are added before any calls to GetAliasName. If GetAliasName is called on an alias that is not known it is either an error in the translation or formatter which needs to be discovered and fixed, or the alias is from an external scope and the formatter is being called on a subset of the entire query (this happens with nested projections). Either way, you need a way to distinguish these errorneous or out of scope aliases from normal resolved aliases, so that's why the GetAliasName uses a different naming scheme when the alias is not known.

wrote Feb 14, 2013 at 7:44 PM