In advanced query being able to set an alias to the output structure
3293
Views
17
Comments
Implemented
Aggregates & Queries
OutSystems 9
When we have the need to invoke the same entity twice in advanced queries we have the absolute need to put an alias in one of them, to distinguish them.

The thing is that service studio puts a warning to it if you use Alias.* ...

Perhaps one could assign an alias to the output structure?
There are some queries where we need to reference the same entity more than once (for example, entity "person" could be referenced twice, with diferent "roles": CLIENT and SUPPLIER).

In this situation, the second reference currently get named "person_2", and it makes confusing to use its columns outside the query editor.

So, it would be nice to be able to somehow "rename" the entity in the query editor, in such a way that we could reference it like "client.name" or "supplier.name" outside the query.

(In SQL we would do it in the FROM clause, like: select ... from person client, person supplier ...).

Merged from 'Set entity "ALIAS" in queries' (idea created on 2010-10-22 22:09:26 by Ricardo Ardito), on 2011-03-26 16:24:25 by Rodrigo Castelo
2016-04-21 20-09-55
J.
 
MVP
absolutely!

Merged from 'Set entity "ALIAS" in queries' (idea created on 2010-10-22 22:09:26 by Ricardo Ardito), on 2011-03-26 16:24:25 by Rodrigo Castelo
A must have! It would improve readability and "code" auto-documentation.

Merged from 'Set entity "ALIAS" in queries' (idea created on 2010-10-22 22:09:26 by Ricardo Ardito), on 2011-03-26 16:24:25 by Rodrigo Castelo
This would help a great deal.

Merged from 'Set entity "ALIAS" in queries' (idea created on 2010-10-22 22:09:26 by Ricardo Ardito), on 2011-03-26 16:24:25 by Rodrigo Castelo
2013-05-16 15-48-18
ovatsus
So instead of using Employee_2, Employee_3, etc.. we can use more meaningfull names like Referal, Manager, etc...

Merged from 'Allow to name repeated Query Entities' (idea created on 2010-05-23 23:45:11 by Gustavo Guerra), on 2011-03-26 16:56:40 by Rodrigo Castelo
It would be nice to set an alias for an entity in a simple query, as it might be confusing when you use the same entity twice (or more) in the same query (e.g., ENTITY and ENTITY_2 are not easily sorted, everytime you need to know which is which).

Merged from 'Set aliases for entities in simple queries' (idea created on 2011-04-14 12:13:12 by Henrique Matos), on 2011-04-20 09:44:30 by Rodrigo Castelo
Seconded for the last remark about simple queries, as it goes for them as well.
More than an year later : 

It would also be great if Service Studio would validate and even auto-complete attributes that come from aliases in advanced queries. Mispells happen all the time (yeah yeah conscience grammar guy : try to hit 20 keys per second and then tell me if only illiterate do it).
+1!

This would be a big improvement in that it would make the code using the resulting structures more readable and enable changing the advanced query with less outside impact.
Voted!!!
2016-11-21 23-23-05
Gonçalo Borrêga
I'm happy to let you know that with OutSystems Platform 9 you can change the name of the output structures in an advanced query.
Enjoy



When we add the same table more than one time to the output, it would be helpful to be able to rename the output.

For example, if we have a table with to foreign keys named CreatedBy and  UpdatedBy from the User Table, when getting the values we would have User and User_2, which is not very intuitive and easy to use.

Merged from 'Alias in the query output' (idea created on 2011-08-31 19:21:37 by Carlos Freitas), on 2014-09-23 23:39:38 by Gonçalo Borrêga
This is a duplicate.

Merged from 'Alias in the query output' (idea created on 2011-08-31 19:21:37 by Carlos Freitas), on 2014-09-23 23:39:38 by Gonçalo Borrêga
Haven't had the chance to peek into Platform 9; is this extended to Simple Queries as well?
Yes it is extended in the Simple Queries too!


2016-04-21 20-09-55
J.
 
MVP
Yay!
Merged this idea with 'Allow to name repeated Query Entities' (created on 2010-05-23 23:45:11 by ovatsus)