Having table-name field to Column class
acorn371 opened this issue · 2 comments
Is it possible to add a table
field to Column class ? It could be useful in queries having joined-tables.
I have two tables (users
and profiles
) having some fields with the same name name
as in the following table definitions:
CREATE TABLE users (
id integer NOT NULL,
name text NOT NULL,
profile_id integer NOT NULL,
CONSTRAINT users_pkey PRIMARY KEY ( id )
);
CREATE TABLE profiles (
id integer NOT NULL,
name text NOT NULL,
CONSTRAINT profiles_pkey PRIMARY KEY ( id )
);
In my query
List<Row> rows = await cnn.query("select users.*,profiles.* from users inner join profiles on users.profile_id=profiles.id").toList();
calling rows.first.getColumns()
I can get a list of Column with two of these having the same name name
because table-name alias was stripped. My software cannot decide which column-name name
belongs to which table.
Moreover, rows.first.toMap()
get me a map with a column-name name
collapsed, loosing a column value.
I know, I could set an different alias to every column having the same name but this approach isn't easily
implemented by a generic software procedure.
Thanks,
Marco
Not sure if it is feasible, since the name is returned by PG server. This package is only a driver. It won't and shan't parse the SQL statement.
Yes, You're probably right, it depends on PS Server and it's correct that a driver don't parse any sql statement at all.
Thank You.