DapperLib / DapperLib/Dapper

Bad SQL generated for Oracle and empty IEnumerable

Open
#202 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

db:oracle
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Dapper generates SQL for Oracle when passing empty IEnumerables to an IN() clause:

var param = new List<string>();
param.Add("PS"); // Add one or more entries
var bar = Database.Query<mytable>(ConnectInfo,
    @"SELECT * FROM mytable WHERE myvarchar2 IN :param", new {param});

...executes without issue, but:

var param = new List<string>();
// param.Add("PS");
var bar = Database.Query<mytable>(ConnectInfo,
    @"SELECT * FROM mytable WHERE myvarchar2 IN :param", new {param});

Fails with: ORA-00923: FROM keyword not found where expected

See my SO question for more details:
http://stackoverflow.com/questions/26877297/dapper-sql-generation-bug-oracle-and-the-sqls-in-clause

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

The issue names no repository file or test. Start by reproducing the two Dapper queries with Oracle, then trace how an empty IEnumerable is expanded for the IN clause. Done means the empty-parameter case no longer produces ORA-00923 and the behavior is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.