Dapper.Contrib icon indicating copy to clipboard operation
Dapper.Contrib copied to clipboard

PostGres SQL - Error on insert

Open Mosheh opened this issue 5 years ago • 2 comments

Simulation: 1 - Remove pluralization: SqlMapperExtensions.TableNameMapper = (type) => { return """+ type.Name + """; };

2 - Create a simple model public class UserData { public int Id{get;set;} public string Name{get;set;} }

3 - Try insert connection.Insert(new UseData{Name='Mosheh'});

Mosheh avatar Aug 11 '20 18:08 Mosheh

@NickCraver The solution is: In SqlMapperExtention line 968: sb.Append($"{tableName}.\"{property.Name}\"");

Mosheh avatar Aug 11 '20 18:08 Mosheh

While this change may fix you, it would break others (whose case depends on the unquoted case insensitivity). Please see DapperLib/Dapper#722 where we aim to give more control over that in the next major version. For now, you can quote your column names in attributes if you want case-sensitive behavior in Postgres :)

NickCraver avatar Aug 29 '20 12:08 NickCraver