Skip to content

Commit

Permalink
Closes #1396. Auto index from v1.9.4 doesn't error on v1.9.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsrinivasan committed Oct 26, 2015
1 parent aa40b62 commit 8e245db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@

3. Fixed tests for `fread` 1378.2 and 1378.3 with `showProgress = FALSE`, closes [#1397](https://github.com/Rdatatable/data.table/issues/1397). Thanks to @JanGorecki for the PR.

4. Worked around auto index error in `v1.9.6` to account for indices created with `v1.9.4`, [#1396](https://github.com/Rdatatable/data.table/issues/1396). Thanks @GRandom.

### Changes in v1.9.6 (on CRAN 19 Sep 2015)

#### NEW FEATURES
Expand Down
7 changes: 7 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -7068,6 +7068,13 @@ Y = data.table(A=2:4, B=5:7)
test(1575.1, X[Y, on=c(A="a")], error="not found in x")
test(1575.2, X[Y, on=c(a="a")], error="not found in i")

# work around for issue introduced in v1.9.4, #1396
X = data.table(x=5:1, y=6:10)
setattr(X, 'index', integer(0))
setattr(attr(X, 'index'), 'x', 5:1) # auto indexed attribute as created from v1.9.4
ans = capture.output(X[, z := 1:5, verbose=TRUE])
test(1576, ans[4], "Dropping index 'x' as it doesn't have '__' at the beginning of index name. It is very likely created using v1.9.4 of data.table.")

##########################


Expand Down
10 changes: 9 additions & 1 deletion src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,15 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values, SEXP v
for (i=0; i<LENGTH(cols); i++) {
tc2 = c2 = CHAR(STRING_ELT(names, INTEGER(cols)[i]-1)); // the column name being updated; e.g. "col1"
while (*tc1) {
if (*tc1!='_' || *(tc1+1)!='_') error("Internal error: __ not found in index name");
if (*tc1!='_' || *(tc1+1)!='_') {
// fix for #1396
if (verbose) {
Rprintf("Dropping index '%s' as it doesn't have '__' at the beginning of index name. It is very likely created using v1.9.4 of data.table.\n", c1);
}
setAttrib(index, a, R_NilValue);
i = LENGTH(cols);
break;
}
tc1 += 2;
if (*tc1=='\0') error("Internal error: index name ends with trailing __");
while (*tc1 && *tc2 && *tc1 == *tc2) { tc1++; tc2++; }
Expand Down

0 comments on commit 8e245db

Please sign in to comment.