SQLite Forum

Aliased function result with the same name issue
Login
Hi, I noticed a little unexpected way Sqlite treats field aliases and would like to make sure this is by design or not. 

In a query like this

  SELECT MyFunction(MyField) as MyField Where MyField<>''

(when the name of the field and the alias are the same)
it looks like the condition is evaluated against the original MyField value, not the result of MyFunction. I checked this with the version 3.35.4. The simplest way to reproduce this is by using Trim function against several rows of repeated space symbols. 

I also checked this in MySql (some old version) and seems like the condition of the query

  SELECT Trim(Txt) as Txt FROM `testspaces` where Txt<>''

references the result of the function, not the original field. 

A sidenote fun fact: recently I found the page with sqlite requirements ([https://www.sqlite.org/requirements.html]) is a very good source of Sqlite knowledge that can be queried alternatively to usual searches like web search or site search. This is due to the fact that it contains the facts  about Sqlite (3243 as of today) in concentrated form so if you're lucky to formulate the query with the right terms, you will get a small set of rows that can be easily digested. I mention this because before posting I queried a table created from today requirements  against "%alias%name%" and didn't find anything related so if the issue is by design then it would be great that a new requirement explaining this will appear in the requirements.

Thanks