Possible bug in SOQL LIMIT clause

bugquerysoql

I've just encountered a weird behaviour of SOQL and I wonder if it's a bug or maybe some feature I do not understand: looks like the compiler lets you add an incorrect LIMIT clause – LIMIT1 for example – and does not indicate any issues with that. It also doesn't limit the query actually.

Following queries: SELECT Id FROM User LIMIT1, SELECT Id FROM User LIMIT43 both result in below:

1646 SOQL results

Any ideas if there's a reason behind this behaviour?


EDIT: turns out the compiler ignores any word added to the end of the query, e.g. SELECT Id FROM User FSAETGSRFESA

Random word SOQL 1646 results

Best Answer

This will be the Alias Notation for objects. E.g.

SELECT count()
FROM Contact c, c.Account a
WHERE a.name = 'MyriadPubs'

In your case LIMIT43 is actually an alias for User. So you will find this works as well:

Select LIMIT43.Id From User LIMIT43
Related Topic