I apologize if this has been asked before but I could not find relevant
answers - or maybe I didn't know how to search.

If a SELECT statement uses qualified column names, sqlite3_column_name()
returns qualified column names for views but not for tables. Shouldn't this
behavior be the same for tables and views?

Example:

SQLite version 3.8.2.

CREATE TABLE foo (col1 INTEGER PRIMARY KEY, col2 TEXT);
CREATE VIEW vfoo AS SELECT * FROM foo;
INSERT INTO foo(col1, col2) VALUES(1, 'a');
SELECT foo.col1, foo.col2 FROM foo;

col1 col2
---- ----
   1 a

SELECT vfoo.col1, vfoo.col2 FROM vfoo;

vfoo.col1 vfoo.col2
--------- ---------
        1 a

The first SELECT statement selects from a table and the second one from a
view, and both use qualified column names. For the first SELECT statement,
the column names returned by sqlite3_column_name() are not qualified, but
for the second one they are.

Previously this behavior was determined by PRAGMA full_column_names and
PRAGMA short_column_names which are currently deprecated. Is there any way
to control this behavior in the current version, other than using column
aliases?

The documentation (http://www.sqlite.org/c3ref/column_name.html) says

"If there is no AS clause then the name of the column is unspecified and
may change from one release of SQLite to the next."

but shouldn't this be at least consistent for tables and views for the same
release of SQLite?


Thanks,

Bogdan Ureche
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to