-
Notifications
You must be signed in to change notification settings - Fork 1
fix: some issues with data output to postgresql #63
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,13 +71,13 @@ def send_runner_metadata_to_postgresql( | |
| ( | ||
| runner.get("id"), | ||
| runner.get("name"), | ||
| runner.get("lastRunId"), | ||
| runner.get("lastRunInfo").get("lastRunId"), | ||
| runner.get("runTemplateId"), | ||
| ), | ||
| ) | ||
| conn.commit() | ||
| LOGGER.info(T("coal.services.postgresql.metadata_updated")) | ||
| return runner.get("lastRunId") | ||
| return runner.get("lastRunInfo").get("lastRunId") | ||
|
||
|
|
||
|
|
||
| def remove_runner_metadata_from_postgresql( | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ def send(self, filter: Optional[list[str]] = None) -> bool: | |||||||
| configuration=self.configuration, | ||||||||
| selected_tables=filter, | ||||||||
| fk_id=run_id, | ||||||||
| replace=False, | ||||||||
| ) | ||||||||
|
||||||||
| ) | |
| ) | |
| return True |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -244,10 +244,11 @@ def test_send_with_exception(self): | |||||||||||||||||||||||
| # Act | ||||||||||||||||||||||||
| with patch.dict(ChannelSpliter.available_interfaces, {"s3": mock_channel_class}): | ||||||||||||||||||||||||
| spliter = ChannelSpliter(mock_config) | ||||||||||||||||||||||||
| result = spliter.send() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Assert | ||||||||||||||||||||||||
| assert result is False | ||||||||||||||||||||||||
| with pytest.raises(Exception): | ||||||||||||||||||||||||
| result = spliter.send() | ||||||||||||||||||||||||
| # Assert | ||||||||||||||||||||||||
| assert result is False | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def test_delete_success(self): | ||||||||||||||||||||||||
| """Test delete method when all targets succeed.""" | ||||||||||||||||||||||||
|
Comment on lines
+249
to
254
|
||||||||||||||||||||||||
| result = spliter.send() | |
| # Assert | |
| assert result is False | |
| def test_delete_success(self): | |
| """Test delete method when all targets succeed.""" | |
| spliter.send() | |
| def test_delete_success(self): | |
| """Test delete method when all targets succeed.""" | |
| """Test delete method when all targets succeed.""" |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion assert result is False will never be executed because it's placed after the line that raises an exception. When spliter.delete() raises an exception, control immediately jumps to the exception handler, skipping this assertion. If the intent is to verify behavior when an exception is raised, this assertion should be removed.
| result = spliter.delete() | |
| # Assert | |
| assert result is False | |
| spliter.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code uses chained
.get()calls on nested dictionaries without checking iflastRunInfoexists or is None. Ifrunner.get("lastRunInfo")returns None, calling.get("lastRunId")on it will raise an AttributeError. Consider using safe navigation or adding a check to handle cases where the nested structure might be incomplete.