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

Upsert() should function on tables w/o a PK #24

Open
Anmol-Tuple opened this issue Jun 7, 2017 · 5 comments
Open

Upsert() should function on tables w/o a PK #24

Anmol-Tuple opened this issue Jun 7, 2017 · 5 comments

Comments

@Anmol-Tuple
Copy link

Anmol-Tuple commented Jun 7, 2017

Hi is there any method to remove only tables while upserting


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@seanharr11
Copy link
Owner

Could you be a more specific? I'm not sure exactly what you mean...

@Anmol-Tuple
Copy link
Author

Hi ,
when I am making drop_database=false each time the data is appending to the table thus making duplicates records

@seanharr11
Copy link
Owner

Does the table with the duplicate records have a primary key? I believe we use the primary key of the table to determine whether a row should be updated or inserted.

@nitishxp
Copy link

what if it does not contain primary keys?

@seanharr11 seanharr11 changed the title Remove only table while upserting Upsert() should function on tables w/o a PK Aug 28, 2017
@seanharr11
Copy link
Owner

There should be 2 fallback options if no primary keys are present on the table (in order):

  1. We gather all FKs, and use them as a "composite primary key" to upsert() on. This will be a common case when dealing with association tables (in many-to-many relations).
  2. We specify the columns that make up the "composite primary key", as a part of the config, for each table that does not have a primary key.

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

No branches or pull requests

3 participants