So if I do our equivalent of the ORM API Misuse case:
IF(RecordExists(SELECT * FROM schema.variants WHERE track_inventory = 0))
{
...
}
(RecordExists is a function that only checks whether the query returned something, and has been marked that way) the compiler will already reduce this to: IF(RecordExists(SELECT FROM schema.variants WHERE track_inventory = 0 LIMIT 1))
{
...
}
And likewise a function that selects all columns from a database and returns only one field, has the select reduced to only selecting that one column.The drawback, of course, is that any SQL features of the underlying database not exposed by the scripting language, are unreachable unless you fallback to sending raw query strings again.