Hello,

On 2016-04-05 19:19, Richard Hipp wrote:

> Please explain why you think it is important to know the "type" of a
> column in a view?

For the same reason as it is important in case of a table. Both could be 
consistent.

> There are further inconsistencies here.  Example:
>
>      CREATE TABLE t1(x INTEGER);
>      CREATE VIEW v1 AS SELECT x FROM t1;
>      CREATE VIEW v2(x) AS SELECT x FROM t1;
>      PRAGMA table_info('v1');
>      PRAGMA table_info('v2');
>
> As of version 3.12.0, the two pragma's give the same answer. but in
> version 3.11.0, they were different.  Which of the two answers
> returned by 3.11.0 is correct?

IMHO, INTEGER. ``v2(x)'' changes nothing but the name of the column. It 
has no impact on the column's affinity.

> Or, consider this situation:
>
>      CREATE TABLE t2(w SHORT INT, x DECIMAL, y BIGINT, z REAL);
>      CREATE VIEW v3 AS SELECT w+x+y+z FROM t2;
>
> What should "PRAGMA table_info('v3')" report as the column type?

Opposite to the above: w+x+y+z loses affinity so it would be displayed 
as an empty string.

> It seems to me that the most consistent answer is that the "type" of
> columns in a VIEW should always be an empty string.

If so, Mike's postulate is arguable. This fact could be mentioned in a 
description of ``table_info'' PRAGMA: in case of views only id and a 
name of a column is meaningful.

-- best regards

Cezary H. Noweta

Reply via email to