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

diff_data detects changes in primary keys, even if ids is specified #31

Closed
lgaborini opened this issue Apr 14, 2021 · 4 comments · Fixed by #35
Closed

diff_data detects changes in primary keys, even if ids is specified #31

lgaborini opened this issue Apr 14, 2021 · 4 comments · Fixed by #35

Comments

@lgaborini
Copy link

Maybe I misunderstand the role of the ids parameter, but records with different primary keys should be treated separately.
Instead, it seems that diff_data detects changes, even if the key is forced.

df_ref <- tibble::tribble(
   ~a, ~b, ~key,
   1, "test1", "key_001",    # only in ref
   2, "test2", "key_002",
   3, "test3", "key_003",
)

df_current <- tibble::tribble(
   ~a, ~b, ~key,
   2, "TEST2", "key_002",    # non-key change
   3, "test3", "KEY_003",    # key change
   4, "test4", "key_004",    # only in current
)


diff_structure <- daff::diff_data(
   data_ref = df_ref,
   data = df_current,
   ids = "key",
   ordered = FALSE
)

diff_structure
#> Daff Comparison: 'df_ref' vs. 'df_current' 
#>     a b            key             
#> --- 1 test1        key_001         
#> ->  2 test2->TEST2 key_002         
#> ->  3 test3        key_003->KEY_003
#> +++ 4 test4        key_004

I would have expected something like:

#> ---  3 test3        key_003
#> +++  3 test3        KEY_003

Even if I compare without the ID, I get the same result:

diff_structure_no_id <- daff::diff_data(
   data_ref = df_ref,
   data = df_current,
   ordered = FALSE
)

diff_structure_no_id
#> Daff Comparison: 'df_ref' vs. 'df_current' 
#>     a b            key             
#> --- 1 test1        key_001         
#> ->  2 test2->TEST2 key_002         
#> ->  3 test3        key_003->KEY_003
#> +++ 4 test4        key_004

Created on 2021-04-14 by the reprex package (v2.0.0)

(I am using the latest daff on CRAN, 0.3.5)

Thanks!

@jasminekhu
Copy link

I am facing the same issue. Even after I specify primary key using ids, the changes with respect to Primary keys provide wrong output as mentioned in example by @lgaborini

@jasminekhu
Copy link

@edwindj Kindly guide

@edwindj
Copy link
Owner

edwindj commented Dec 17, 2021

Thanks for the reminder: will look into it next week!

@jasminekhu
Copy link

HI @edwindj , did you get a chance to look into the Primary key issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants