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

update/updsert will delete keys in row? #53

Closed
hszcg opened this issue Dec 4, 2013 · 4 comments
Closed

update/updsert will delete keys in row? #53

hszcg opened this issue Dec 4, 2013 · 4 comments

Comments

@hszcg
Copy link
Contributor

hszcg commented Dec 4, 2013

hi folks,

I just found that in https://github.com/pudo/dataset/blob/master/dataset/persistence/table.py#L128

we actually delete keys in the row, e.g.

c = {'id':1, 'val':'name'}
table.upsert(c, ['id'])
# NOW c == {'val': 'name'} HERE!

is there anyway to avoid this?
i mean keeping c unchanged after calling update/upsert.

Thanks.

@pudo pudo closed this as completed in ff247f1 Dec 4, 2013
@pudo
Copy link
Owner

pudo commented Dec 4, 2013

Thanks for reporting this, it'll be in the next release.

@hszcg
Copy link
Contributor Author

hszcg commented Dec 4, 2013

@pudo

Thanks for the quick hands.
Personally, I would suggest that maybe you could use the following code instead, which might be more efficient.

clean_row = row.copy()
for key in keys:
    if key in clean_row.keys():
        del clean_row[key]

Just a suggestion, totally up to you, thanks.

@pudo
Copy link
Owner

pudo commented Dec 4, 2013

Changed it accordingly, thanks for the pointer.

@hszcg
Copy link
Contributor Author

hszcg commented Dec 5, 2013

@pudo

Actually, I mean row.copy() rather than copy.copy(row), which is way more efficient.
Please check the performance benchmark on http://stackoverflow.com/a/5861653/1143054

Thanks,

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

2 participants