 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Cvijo
Joined: 28 Aug 2009 Posts: 4 Country: Croatia |
|
How to disable autocomplete after .columName |
|
Hi,
i am having problems with autocomplete and dont know if it is able to disable that option.
For example if u alread have SQL statment like this:
Select
table1.field1,
table1.field2,
table1.field3
from table1
and when u add table1.fie -> autocomplete (field4) then SQL Assistant automaticly add from table1 again (i dont have alias for table1 in main select)
so u get this
Select
table1.field1,
table1.field2,
table1.field3,
table1.filed4 from table1 <-- this all line is automaticly inserted when you choose column from popup menu
from table1
but if u have aliad on main select than it wont add "from table1" part automaticly. We dont use alias on tables when we preform select query and whenever u need to add new field and start typing columname. and you choose field from popup menu it always add that "from table" part.
Select
t1.field1,
t1.field2,
t1.field3,
t1.field4 <-- working fine when you use alias on table names
from table1 t1
Thanks in advance
|
|
Fri Aug 28, 2009 9:14 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Which version is that?
|
|
Fri Aug 28, 2009 9:24 am |
|
 |
Cvijo
Joined: 28 Aug 2009 Posts: 4 Country: Croatia |
|
|
|
version 4.6.12
|
|
Fri Aug 28, 2009 9:25 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I can reproduce this issue.
Here is partial workaround that I can offer. Instead of typing table name, dot, just type comma at the end of previous column and then at once select all additional columns you want to add.
Just out of my curiosity, why do you enter so much extra text? Table name prefixes are not required in the SELECT part of the query.
|
|
Fri Aug 28, 2009 10:23 am |
|
 |
Cvijo
Joined: 28 Aug 2009 Posts: 4 Country: Croatia |
|
|
|
Hi sysOp and as i mention before we alter our selects alot and that means i already have many columns in stored procedure so i just need to add few more.
As for other part of course you dont need table prefix but i gave simple example here our selects joins more than 10 tables usually so u have same column names in some tables (like column Name, or column Description etc) so you have to add tableName.ColumnName and besides its how it should be always, becouse if u type like that u are sure u wont have problmes in future when u will have to join mybe another table.
That workaround that you suggested wont work in most of our cases :(.
I am suprised there is no option to disable that auto adding "from table" and if its not you should consider putting that in configuration :)
Thank you
|
|
Sat Aug 29, 2009 3:03 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I'm sure that adding "from table" in this case is not an intended behavior and it looks like a bug to me. That doesn't happen if table aliases are used. I'm going to submit this as a bug to our project tracking system.
PS. Using table aliases also help swith self-joins and with joins for the same table across sub-queries while using table names as prefixes prevents such things. It also cuts the amount of code you need to type, making your job more efficient, and makes the code more readable and more efficient from performance point of view. (yes, it makes a small difference for code execution, procedure code is compiled as p-code, not as machine executable code) Generally, using table names as prefixes is a bad practice.
Here is an example in which using table prefixes is not going to work.
 |
 |
SELECT e.emp_id,
e.emp_name,
e.manager_id,
m.emp_name AS manager_name,
(SELECT count(*) FROM demo.employee t WHERE t.dept_id = e.dept_id) AS dept_head_count
FROM demo.employee e
LEFT JOIN demp.employee m
ON m.emp_id = e.manager_id
ORDER BY e.emp_id |
Last edited by SysOp on Mon Aug 31, 2009 2:25 am; edited 1 time in total |
|
Sat Aug 29, 2009 10:58 am |
|
 |
Cvijo
Joined: 28 Aug 2009 Posts: 4 Country: Croatia |
|
|
|
Thank you for helping out and trying to solve this issue.
As for aliases in talbes i agree with you if there is few developers woking on stored procedures etc. In my case we have policy about name convencion but if everyone trying to put their ailas name table, reading stored procedure becomes nightmare so we never used alias if we dont need to and tbh i dont see any drawback using real table names and not alias, but as said before it something we came up with :)
In you example its easy to read alias e and alias m and read all SP, but try making join with more than 10 tables with simular names so u have to use at least 5 letters for alias, so real table name come as better solution to us at least, and when you see table1.columnName you dont have to look up like to check what table is that like you have to in alias names (of course only if u dont put alias like long word with explnation wich table is it :) )
|
|
Mon Aug 31, 2009 2:09 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Just in case, the issue tracking number for this bug is SQL-0004796. It should be addressed in the next maintenance release.
|
|
Mon Aug 31, 2009 2:22 am |
|
 |
|
|
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
|
|
|