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

Fix #1094 #1096

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Fix #1094 #1096

merged 2 commits into from
Sep 9, 2024

Conversation

CBroz1
Copy link
Member

@CBroz1 CBroz1 commented Sep 9, 2024

Description

#1050 migrated from a for-loop-insert pattern to a for-loop-append pattern, but did not check whether or not the appended list was edited in subsequent iterations.

# insert pattern
for item in my_list: 
    item.update(other_data)
    tbl.insert1(item)

# append pattern
inserts = []
for item in my_list:
    item.update(other_data)
    inserts.append(my_func(item))
tbl.insert(inserts)

The former inserts the data as-is, preventing subsequent loop iterations from changing in-memory values. The latter reduces database calls to speed up the process and prevent inserts in the event a later iteration fails, but is susceptible to later iterations doing in memory manipulations of the previous insert. Making sure to append item.copy() fixes this issue.

While this bug is present in a release, using the bugged version will result in the error shown in #1094 - integrity error because the part table will refer to a non-existent master. sg_keys is susceptible to this effect, but not sge_keys as the sge_key is decomposed with ** when appended to the inserts list.

Checklist:

  • No. This PR should be accompanied by a release: (yes/no/unsure)
  • N/a. If release, I have updated the CITATION.cff
  • No. This PR makes edits to table definitions: (yes/no)
  • N/a. If table edits, I have included an alter snippet for release notes.
  • N/a. If this PR makes changes to position, I ran the relevant tests locally.
  • I have updated the CHANGELOG.md with PR number and description.
  • N/a. I have added/edited docs/notebooks to reflect the changes

@CBroz1 CBroz1 marked this pull request as ready for review September 9, 2024 21:05
@CBroz1 CBroz1 requested a review from edeno September 9, 2024 21:05
@edeno edeno merged commit b9e363f into LorenFrankLab:master Sep 9, 2024
7 checks passed
@CBroz1 CBroz1 deleted the 1094 branch October 22, 2024 15:12
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 this pull request may close these issues.

2 participants