Am 09.12.2009 um 13:42 schrieb Alexey Pechnikov:
> Hello!
>
> On Wednesday 09 December 2009 15:07:16 Pavel Ivanov wrote:
>> It's been said in this list not once already: unless you're using "as
>> ..." to name the column it's not guaranteed to have any particular
>> name you expect it to. So it's not a bug.
>
> This is bug becouse the column with alias will be renamed. As example:
>
> sqlite> create table test (id INTEGER PRIMARY KEY, a text);
> sqlite> insert into test (a) values ('test');
> sqlite> create view view_test as select rowid,a as id from test;
> sqlite> .header on
> sqlite> select * from view_test;
> id|id:1
> 1|test
>
> The result is wrong becouse fileld "id" must be equal to 'test'.
INTEGER PRIMARY KEY is handled as a special case - see
<http://www.sqlite.org/lang_createtable.html
>:
"SQLite uses dynamic typing instead of static typing. Except for the
special case of INTEGER PRIMARY KEY, SQLite will allow values of any
type to be stored in any column regardless of the declared datatype of
that column. The declared datatype is a type affinity that SQLite
attempts to comply with, but the operation will proceed even if
compliance is not possible."
and
"If a column is declared to be an INTEGER PRIMARY KEY, then that
column is not a "real" database column but instead becomes an alias
for the rowid. Unlike normal SQLite columns, the rowid must be a non-
NULL integer value. The rowid is not able to hold floating point
values, strings, BLOBs, or NULLs.
An INTEGER PRIMARY KEY column is an alias for the 64-bit signed
integer rowid."
</jum>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users