On Sun, Feb 2, 2014 at 12:23 PM, Charles Leifer <colei...@gmail.com> wrote:

> I was surprised to find that, depending on whether I queried a table or a
> view, sqlite3_column_name would return different values for the column
> name. Specifically, when the table is aliased and the columns in the SELECT
> clause are quoted, sqlite returns an unquoted, unaliased column name, e.g.
> "
> t1.name" -> name. When querying a view, though, sqlite will return the
> quoted, aliased column name, e.g. "t1.name" -> "t1.name". Does this
> qualify
> as a bug, or is this intended behavior?
>

There is no "intended" behavior.
http://www.sqlite.org/c3ref/mark/column_name.html?If+there+is+n*fied

If the result of sqlite3_column_name is important, please us an AS clause
to set it to exactly what you want.


>
> I observed this with sqlite versions 3.8.2, 3.7.13 and 3.7.9.
>
> Here is a short python script exemplifying the behavior:
>
> import sqlite3
> conn = sqlite3.connect(':memory:')
> cursor = conn.cursor()
>
> cursor.execute('create table people (name);')
> cursor.execute('insert into people values (?)', ('charlie',))
>
> cursor.execute('select t1.name from people as t1')
> print cursor.description
> # (('name', None, None, None, None, None, None),)
>
> cursor.execute('create view people_view as select * from people')
> cursor.execute('select t1.name from people_view as t1')
> print cursor.description
> # (('t1.name', None, None, None, None, None, None),)
>
> Thanks in advance,
>
> Charlie
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to