 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
Alias recognition anomaly |
|
SA has some issues with alias recognition when DELETE is involved. Let's have the following table:
 |
 |
CREATE TABLE dbo.mytable (a INT PRIMARY KEY, b INT NOT NULL, c INT NULL) |
The structure
 |
 |
<CLAUSE>
FROM dbo.mytable AS m
WHERE| |
behaves the way it should for both SELECT or UPDATE clauses. As soon as you press space, a popup appears that includes the alias m for mytable. Pressing 'm' filters the options and pressing '.' after rules out everything else but the aliased table and its columns.
It works with DELETE even if it is syntactically incorrect. I can get the code below by filtering with 'm', '.', 'a':
 |
 |
DELETE
FROM dbo.mytable AS m
WHERE m.a = 1
|
Of course, this code won't compile.
But as soon as it is corrected by adding the alias 'm' to DELETE the alias recognition no longer works properly.
 |
 |
DELETE m
FROM dbo.mytable AS m
WHERE|
|
Pressing space does yield the popup with the alias and pressing 'm' filters but pressing '.' breaks something and the popup vanishes completely. Any idea what may possibly go wrong here?
|
|
Fri Jun 29, 2012 6:21 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Thank you for very detailed and thorough explanation, which is very helpful. Essentially what you have demonstrated here means that in
DELETE [alias]
FROM [table] AS [alias]
WHERE [alias]. [ not working correctly here]
the [alias] in the WHERE clause is not treated as an alias, but rather as a table name likely because that name is found first in the DELETE line and there appears no look-ahead check or that check is not working correctly. Since there is no actual table in the database named [alias], no column popup appears in the WHERE line after "[alias]."
Interesting to note that after the WHERE keyword (WHERE and nothing else after it) pressing space bar causes the correct column popup to appear on the screen with the correct alias referenced at the top of the list. Somehow after the alias + dot combination in the WHERE clause, it doesn't recognize it correctly anymore.
I have submitted a new bug report #SA0019836
|
|
Fri Jun 29, 2012 11:23 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Thank you very much.
|
|
Fri Jun 29, 2012 5:01 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|