Don't name everything T1


For trouble shooting it would be much easier if not everything in the code was called T1. Trying to find the source of T1.[column_name] can be pretty time consuming since there are multiple T1 aliases used within the select statements created by the GUI. 

 

Hi @Erwin Ekkel,

Can you elaborate a bit more on the actual idea, instead of the current situation? Do you have an example of code that is time consuming to troubleshoot? And what would you suggest as a solution to help clarifying things? Perhaps this will help you in gathering votes.


Here is a simple example of the role screen in the SF. Actual screens within end applications can have several T1's. Role is T1, Model is T1 and Branch is T1. Especially with the way the code is structured with sub query in sub query it can take some back tracking to find the source table of t1. The purpose of an alias is to make the code easier to read, not to confuse.

select t1.[model_id]
     , t1.[branch_id], t1.[role_id]
     , t1.[role_description]
     , t1.[all_rights]
     , t1.[insert_user]
     , t1.[insert_date_time]
     , t1.[update_user]
     , t1.[update_date_time]
     , t1.[generated_by_control_proc_id]
from [role] as t1
     left outer join (
select t1.[model_id], (t1.model_id
)
 as [model_id_display]
from [model] as t1
) as t2 on t1.[model_id] = t2.[model_id]
     left outer join (
select t1.[model_id], t1.[branch_id], (concat(t1.branch_id,
       case when exists (select 1 
                         from merge_session m
                         where t1.model_id = m.model_id 
                           and t1.branch_id in (m.merge_from_branch_id, m.merge_into_branch_id) 
                           and m.completed = 0)
            then ' (merging)'
            when t1.active = 0
            then ' (inactive)'
       end)
)
 as [branch_id_status]
from [branch] as t1
) as t3 on t1.[model_id] = t3.[model_id] and t1.[branch_id] = t3.[branch_id]
where (t1.[model_id] = 'DATECOM' and t1.[branch_id] = 'MAIN')
order by t2.[model_id_display], t3.[branch_id_status], t1.[role_id]


Hello Erwin,

The reason that every alias is t1 is a very conscious decision that was made for this reason:
 

https://docs.thinkwisesoftware.com/docs/sf/subjects_data#prefilter-type

 

And this also applies to expression columns:

https://docs.thinkwisesoftware.com/docs/sf/data_model#expression-dependencies

 

The alias used must at the very least be deterministic, otherwise it will be impossible to write SQL prefilters or expressions. They could be deterministic AND also more descriptive than they currently are, but this would be a breaking change — many existing SQL prefilters and expressions that use ‘t1’ would break. This alone makes this idea unfeasible in my eyes.


NewClosed