Skip to content

(FM-8879) Handle T-SQL Errors Properly #349

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

Conversation

RandomNoun7
Copy link
Contributor

The previous commit that improved T-SQL error handling was incomplete.
That commit (9b8a0fe) was not able to
overcome an important issue.

The issue was that if there was a successfull row insert into a table
the Errors collection of the ADODB.Connection would be empty, even
if an error was deliberately thrown using the THROW keyword.

It turns out that the successfull row insert was causing a text return
value, and it's a known issue that if values are returned to the object
that the Errors collection will be empty.

We know now that turning SET NOCOUNT ON in the beginning of the query
will suppress that text status message and allow more errors to be
properly detected in the ADODB.Connect object, and handled properly
in the module's onlyif clause.

@RandomNoun7 RandomNoun7 requested a review from a team as a code owner March 4, 2020 05:32
@RandomNoun7 RandomNoun7 force-pushed the tickets/FM-8879-handle-t-sql-errors branch 4 times, most recently from e9daf11 to 4ea829d Compare March 4, 2020 06:07
@codecov-io
Copy link

codecov-io commented Mar 4, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@8d44d62). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #349   +/-   ##
=========================================
  Coverage          ?   56.25%           
=========================================
  Files             ?       20           
  Lines             ?      759           
  Branches          ?        0           
=========================================
  Hits              ?      427           
  Misses            ?      332           
  Partials          ?        0
Impacted Files Coverage Δ
lib/puppet/property/sqlserver_tsql.rb 100% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d44d62...d741bd7. Read the comment docs.

The previous commit that improved T-SQL error handling was incomplete.
That commit (9b8a0fe) was not able to
overcome an important issue.

The issue was that if there was a successfull row insert into a table
the `Errors` collection of the ADODB.Connection would be empty, even
if an error was deliberately thrown using the `THROW` keyword.

It turns out that the successfull row insert was causing a text return
value, and it's a known issue that if values are returned to the object
that the Errors collection will be empty.

We know now that turning `SET NOCOUNT ON` in the beginning of the query
will suppress that text status message and allow more errors to be
properly detected in the ADODB.Connect object, and handled properly
in the module's `onlyif` clause.
@RandomNoun7 RandomNoun7 force-pushed the tickets/FM-8879-handle-t-sql-errors branch from 4ea829d to d741bd7 Compare March 4, 2020 06:10
@sanfrancrisko sanfrancrisko merged commit d9e9162 into puppetlabs:master Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants