-
Notifications
You must be signed in to change notification settings - Fork 3
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
creating a new column does not work when using odbc::odbc() as a connection #5
Comments
Good that you are checking against a postgress db. |
I also checked it with a SQL server db, and the same issue arises. |
Could you check if the issue is resolved using the latest version? (Today rather busy with other obligations) |
Yes, I tested it with Postgres and odbc on my home pc and it seems to work. I still working on creating proper tests for all database connections using docker(I was sick for the main part of this week). It solved the original problem in this issue but it might be a good idea to have automated tests for multiple SQL data types, which I'm still working on, before resolving the issue. |
Nice! Removing COLUMN also seems to work for the other databases: made it a bit more flexible. |
If a NA value is set for a new column the whole column turns into a character column on Postgres14.
If the same column is overwritten then the type is set correctly. |
Hmm, weird! |
Yes, I am unsure about the reason behind this as of yet.
|
I added a test with this code for sqlite and duckdb and there it seems to work ok. Another thing you could try is to use |
It also does this also using Rpostgres::Postgres() as a driver. And setting the value to |
Hmm, what interested to see what the query is in dplyr::show_query(tab) at line 19 in |
The query made by
The call to
Which produces a table with the new_gear column being of type chr. If a |
Yields an error in the SQL syntax:
ERROR: syntax error at or near "2" <SQL> 'ALTER TABLE "dcmodifydb_2508036" ADD COLUMN "new_gear" 2;'
This is because of the usage of DBI::dbColumnInfo(rs) in alter_stmt(). If odbc::odbc is used as the connection, DBI::dbColumnInfo(rs) yields a dataframe like:
Instead the actual types as a character are needed in the second column
See:
issue1
issue2
The text was updated successfully, but these errors were encountered: