DapperLib / DapperLib/Dapper

Add SQL text to exceptions

Open
#943 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:settings feature request
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

I'm experiencing an issue that appears to be related to #565, but because the error is a syntax error, there's no opportunity for me to examine the actual text that got sent to the database. It doesn't get logged in Oracle's metadata tables (like V$SQL), and unfortunately, OracleException doesn't seem to contain the SQL text, either. Maybe I could get it via some profiling tool, but this feels like overkill and and isn't applicable if you're not using a web application.

It would be nice if I could see the exact SQL text when errors occur so I don't have to guess as much about what the problem might be. I believe a simple way this could be added is by storing it the Data property of an exception:

try {
    // Do whatever Dapper does
}
catch (Exception ex) {
    ex.Data["fullSql"] = actualSqlSentToTheDb;
    throw;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Dapper's database execution and exception paths to identify where the submitted SQL is still available. Confirm the desired behavior with a syntax-error scenario and verify that the resulting exception exposes the exact SQL text through its Data property.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.