[yunqa.de] Re: SQLite metadata

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Fri, 05 Jun 2009 12:22:42 +0200

At 09:08 05.06.2009, Radovan Antloga wrote:

>For expression fields (count(*), avg(), sum()) I have added
>ability to read type from field alias (count(*) "CNT:integer")
>so I could map field in query. If I forget alias, I map fields with
>no affinity to variants. I wonder to ask drh if he can improve
>sqlite to return affinity (not just NONE) for expression fields.

Consider this query:

  drop table if exists t;
  create table t (c integer);

  insert into t values (1);
  insert into t values (2);
  insert into t values (3);

  select  
    typeof (
      case c 
        when 1 then cast (c as integer)
        when 2 then cast (c as text)
        when 3 then cast (c as real)
      end)
    from t;

The SELECT results shows that, because of SQLite's dynamic typing, a single 
expression column can (intentionally so) return different types in different 
rows. This makes it impossible to determine their column type before all row 
values are examined. Hence expressions make no promise and simply carry 
affinity NONE.

The "sqlite-users" mailing list is the recommended place to share and discuss 
feature requests with the SQLite core developers.

But I believe that the chances that the expression type enhancement will be 
implemented are very slim. 

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: