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

Return insert_count on .save() #67

Merged
merged 4 commits into from Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions postgres_copy/copy_from.py
Expand Up @@ -101,6 +101,8 @@ def save(self, silent=False, stream=sys.stdout):
"%s records loaded\n" % intcomma(insert_count)
)

return insert_count
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like a unit test yet that verifies this number is returned, and that it is accurate.


def get_field(self, name):
"""
Returns any fields on the database model matching the provided name.
Expand Down
9 changes: 5 additions & 4 deletions postgres_copy/copy_to.py
Expand Up @@ -24,10 +24,11 @@ def setup_query(self):
for field in self.query.copy_to_fields:
# raises error if field is not available
expression = self.query.resolve_ref(field)
if field in self.query.annotations:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems like a good one, but unrelated to insert_count. Is that right, or am I missing something?

selection = (expression, self.compile(expression), field)
else:
selection = (expression, self.compile(expression), None)
selection = (
expression,
self.compile(expression),
field if field in self.query.annotations else None,
)
self.select.append(selection)

def execute_sql(self, csv_path):
Expand Down