Skip to content

fix: Don't call RowsAffected on query error#17568

Merged
kodiakhq[bot] merged 6 commits intocloudquery:mainfrom
erezrokah:fix/dont_call_rows_affected
Apr 9, 2024
Merged

fix: Don't call RowsAffected on query error#17568
kodiakhq[bot] merged 6 commits intocloudquery:mainfrom
erezrokah:fix/dont_call_rows_affected

Conversation

@erezrokah
Copy link
Copy Markdown
Member

@erezrokah erezrokah requested review from a team and bbernays and removed request for a team April 9, 2024 09:29
@erezrokah erezrokah added the automerge Automatically merge once required checks pass label Apr 9, 2024
@erezrokah erezrokah requested a review from candiduslynx April 9, 2024 09:29
if rowsErr != nil {
return rowsErr
}
c.logger.Debug().Str("query", query).Any("values", args).Int64("rowsAffected", rowsAffected).Msg("exec query")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This wouldn't log rowsErr or the query err and you'd only get debug messages for successful queries.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cool, so I guess we can keep this log 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well actually won't returning the error make it so it's logged always?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Anyway maybe keep it since we don't want to fail if we couldn't write a debug log

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in c11c402

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually when I look at the previous code, we would return rowsErr even if err was nil. Not sure that is what we want if the intention was only to log it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Previous code would return all errors (if any) thanks to the errs := errors.Join(err, rowsErr) line.

Copy link
Copy Markdown
Member Author

@erezrokah erezrokah Apr 9, 2024

Choose a reason for hiding this comment

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

Previous code would return all errors (if any) thanks to the errs := errors.Join(err, rowsErr) line

It won't since it panics in case of initial error 🙃

Copy link
Copy Markdown
Member

@disq disq Apr 9, 2024

Choose a reason for hiding this comment

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

c11c402 isn't the same as before, ideally if c.spec.Debug is on, it should log the query and error before returning (not running rows affected)

An easier approach could be to check if err is nil inside c.spec.Debug and run rowsaffected and join the errors (or just don't care about the rowsaffected error) inside the block.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe 011c48b to reduce the nesting?

@erezrokah erezrokah requested a review from disq April 9, 2024 09:49
@erezrokah erezrokah force-pushed the fix/dont_call_rows_affected branch from 249a668 to 011c48b Compare April 9, 2024 10:13
@kodiakhq kodiakhq bot merged commit 68cf566 into cloudquery:main Apr 9, 2024
kodiakhq bot pushed a commit that referenced this pull request Apr 9, 2024
🤖 I have created a release *beep* *boop*
---


## [1.0.6](plugins-destination-motherduck-v1.0.5...plugins-destination-motherduck-v1.0.6) (2024-04-09)


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.36.4 ([#17485](#17485)) ([f370de4](f370de4))
* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.36.5 ([#17526](#17526)) ([554c499](554c499))
* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.37.0 ([#17532](#17532)) ([8080970](8080970))
* Don't call `RowsAffected` on query error ([#17568](#17568)) ([68cf566](68cf566))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
erezrokah pushed a commit that referenced this pull request Apr 9, 2024
🤖 I have created a release *beep* *boop*
---


##
[5.5.3](plugins-destination-duckdb-v5.5.2...plugins-destination-duckdb-v5.5.3)
(2024-04-09)


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.36.4
([#17485](#17485))
([f370de4](f370de4))
* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.36.5
([#17526](#17526))
([554c499](554c499))
* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.37.0
([#17532](#17532))
([8080970](8080970))
* Don't call `RowsAffected` on query error
([#17568](#17568))
([68cf566](68cf566))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@erezrokah erezrokah deleted the fix/dont_call_rows_affected branch April 10, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants