[R] sqlSave, fast=F option, bug?

Paul MacManus paul.macmanus at gmail.com
Wed Oct 18 06:01:36 CEST 2006


Hi,

Using the fast=F option, sqlSave saves without matching column names.
It looks like a bug to me..........

Here's a simple (artificial) example.
-----------------------------------------
Create a dataframe and save it to a database table "test" as follows:

df <- data.frame(T=1, S=10)
sqlSave(channel, df, "test", rownames=F)

The table now looks like

T  S
1  10

If I create another dataframe and save as follows

df <- data.frame(S=20, T=2)
sqlSave(channel, df, "test", rownames=F, append=T)

Then table "test" now looks like

T  S
1  10
2  20

The important point is that although S was the first column of df,
sqlSave checked the column names and matched the corresponding columns
of df and table "test".

However, if I now create another dataframe and save it using the
fast=F option as follows

df <- data.frame(S=30, T=3)
sqlSave(channel, df, "test", rownames=F, append=T, fast=F)

the table test now looks like

T  S
1  10
2  20
30 3

In other words, sqlSave didn't check column names, it simply mapped
column 1 to column 1 and column 2 to column 2.
---------------------------------

This cannot be right. Opinions?

I'm using R 2.3.0 and package RODBC 1.1-7 on Windows XP with MS SQL Server



More information about the R-help mailing list