Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Error when 'in' query parameter is an empty array

Open soul-soft opened this issue 2 years ago • 3 comments

MySQL 5.6 does not seem to support 'select * from students (id in (select null where 1=0))'

soul-soft avatar Apr 25 '23 07:04 soul-soft

//file:SqlMapper.cs
//line:2340
  var multiExec = GetMultiExec(value);
  if (multiExec != null)
  {
      StringBuilder sb = null;
      bool first = true;
      foreach (object subval in multiExec)
      {
          if (first)
          {
              sb = GetStringBuilder().Append('(');
              first = false;
          }
          else
          {
              sb.Append(',');
          }
          sb.Append(Format(subval));
      }
      if (first)
      {
          return "(select null where 1=0)";
      }
      else
      {
          return sb.Append(')').ToStringRecycle();
      }
  }

Please allow configuration of '(select null where 1=0)'

soul-soft avatar Apr 25 '23 07:04 soul-soft

help me!

soul-soft avatar Apr 28 '23 01:04 soul-soft

Duplicate of https://github.com/DapperLib/Dapper/issues/565

bgrainger avatar May 04 '23 23:05 bgrainger