5
 Followers
44
 Likes

Code-quality Aggregate GetById default max 1 record

Aggregates & Queries
New

When creating an aggregate with the PK, please set the Max Records default to 1. 

May sound a bit trivial, and this is just an idea from a code-quality point of view :-) making the developer aware that the property Max records need to have a value. Otherwise you might run into an Unlimited Result-set impacting your application in a negative way.

Created on 19 Mar 2019
Comments (21)

The problem is, when someone then edits that query in a way where it SHOULD return multiple results... and then they don't know/remember to change it... it still works that way.

I think maybe the best way to do this is for the optimizer to silently add it if:

* There are no filter conditions other than the ID

* There is only one Source

If it was done like this, rather than by just automatically setting "Max Records", this would be a great change.

J.Ja

Changed the category to Aggregates & Queries


+1

Agree, it would be good feature to have.

+1

Merged this idea with 'Set Max. Records to 1 when' (created on 14 Jan 2020 13:59:11 by Beatriz Silva)

When developer implements a query "By Id" using Scaffolding it would be useful for performance and best practices matters to automatically set the Max. Records property to 1.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Excellent idea Beatriz! +1



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Changed the category to Aggregates & Queries




This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Can be merge with older simular idea: https://www.outsystems.com/ideas/6582/code-quality-aggregate-getbyid-default-max-1-record?IsFromAdvancedSearch=True

It's worthwhile reading this idea as Justin James has some good observation on how it could better be implemented.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

. Very interesting! .



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Simple but effective



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

+1



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

As Daniël pointed a similar idea exists already, Let's combine these to get more votes.





This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Also when Max Records is 1 then it doesn't make sense to have sorting on any column.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

If we are talking of scaffolding, I agree with both MaxRecords=1 and no Order By Section.


If it is for any ById I disagree because you can select on the Detail Entity by HeaderId and if MaxRecords is 1 by default, it can be forgotten and some results will be missed.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

I get it, but I don't think it's intuitive that the Name field will affect a property in such a strong way.

I'd rather have queries with ById sufix have the Max Records property be mandatory and empty in this case, so that the dev's attention will be drawn to the error in red and a 1 or any number can be appropriately set.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Not by name Filipe. By name is error prone. By scaffolding.



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:33 by Nuno Reis

Should have red it more carefully, you are right Nuno.

thanks



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:34 by Nuno Reis

Please explain how this is different from the GetX function.
IE GetUser(ID)->Record



This comment was:
- originally posted on idea 'Set Max. Records to 1 when' (created on 14 Jan 2020 by Beatriz Silva)
- merged to idea 'Code-quality Aggregate GetById default max 1 record' on 05 Feb 2020 10:09:34 by Nuno Reis

It is the same John, but when you drag Id to an Action, an aggregate by id is created, not a Get. William/Beatriz 's idea is to optimize such query.


Daniel, thanks for the heads up. The ideas combined have over 40 votes!

views
455
Followers
5