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

Print SQL statement in error logs #55

Closed
wants to merge 1 commit into from
Closed

Conversation

jeyhun
Copy link
Contributor

@jeyhun jeyhun commented Jul 27, 2023

Started including SQL statement in errors returned by DataStore, if the error was because SQL statement failed to execute

Sample error returned by Insert method:

SQL statement could not be executed [dbName=testcrudwithmismatchingorgid, SqlStmt=INSERT INTO "application" ("application_id","name","org_id") VALUES ('id-8674665223082153551','New app','')]
	ERROR: new row violates row-level security policy for table "application" (SQLSTATE 42501)

This PR resolves issue #50

@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2023

Codecov Report

Merging #55 (67c4530) into main (9b232f3) will increase coverage by 0.93%.
The diff coverage is 75.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
+ Coverage   70.56%   71.49%   +0.93%     
==========================================
  Files          12       12              
  Lines        1410     1421      +11     
==========================================
+ Hits          995     1016      +21     
+ Misses        328      320       -8     
+ Partials       87       85       -2     
Flag Coverage Δ
unit-tests 71.49% <75.00%> (+0.93%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
pkg/datastore/database.go 58.78% <75.00%> (+3.49%) ⬆️

Started including SQL statement in errors returned by DataStore, if the error was because SQL statement failed to execute
@jeyhun jeyhun marked this pull request as ready for review July 27, 2023 23:49
@krishnamiriyala
Copy link
Contributor

Let's not dump full stmt inside error, it could have unwanted consequences with security in callers. I prefer debug/trace log instead in a module.

@krishnamiriyala krishnamiriyala deleted the print-SQL-stmt-in-errors branch September 19, 2023 19:06
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.

4 participants