Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Think about dbColumnInfo() and dbFetch() output for unnamed columns #50

Closed
krlmlr opened this issue Nov 8, 2015 · 7 comments
Closed

Comments

@krlmlr
Copy link
Member

krlmlr commented Nov 8, 2015

Should probably have NA in the "name" column, currently it's "NULL" or "?column?".

DBItest: "column_info".

@hadley
Copy link
Member

hadley commented Nov 9, 2015

What does an unnamed column mean in SQL? Oh you mean like a computed column?

@krlmlr
Copy link
Member Author

krlmlr commented Nov 9, 2015

The result of SELECT 1 UNION SELECT 2 is a two-row table with an unnamed column. It's valid SQL and can occur, and we should be able to handle it reasonably, also in dbFetch() and dbGetQuery().

@krlmlr krlmlr changed the title Think about dbColumnInfo() for unnamed columns Think about dbColumnInfo() and dbFetch() output for unnamed columns Nov 9, 2015
@hadley
Copy link
Member

hadley commented Nov 9, 2015

SELECT 1 + 2 is an even simpler reprex. Agreed that NA most is reasonable here.

@krlmlr
Copy link
Member Author

krlmlr commented Nov 9, 2015

Not sure anymore: What should dbFetch() return for SELECT 1, 2? Data frames with two columns named "" don't seem to work well. Perhaps we should mandate a naming scheme for unnamed columns (e.g., implement a helper in DBI), and use this scheme also in dbColumnInfo().

@hadley
Copy link
Member

hadley commented Nov 9, 2015

Hmmm, maybe data.frame(X1 = 1, X2 = 2) ? So need to fill in missing variable names with auto generated in both places.

@krlmlr
Copy link
Member Author

krlmlr commented Apr 17, 2017

The data frame should have unique names, even for queries like SELECT 1, 1. For SQLite, we can determine if it's a computed column with column_database_name(), but I'm not sure about other backends. I think we're on the safer side if we don't specify that computed columns need to have artificial names.

@krlmlr
Copy link
Member Author

krlmlr commented Dec 18, 2017

Closing in favor of r-dbi/DBItest#137.

@krlmlr krlmlr closed this as completed Dec 18, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants