- 增加 PostgreSQL 特有功能 On Conflict Do Update 功能;

This commit is contained in:
28810
2019-11-13 16:35:13 +08:00
parent e0030b0c00
commit 24e2c098a4
2 changed files with 20 additions and 21 deletions

View File

@ -89,8 +89,7 @@ namespace FreeSql.PostgreSQL.Curd
public string ToSql()
{
var sb = new StringBuilder();
var insertSql = _pgsqlInsert.ToSql();
sb.Append(insertSql).Insert(insertSql.IndexOf('('), " AS _ftb_ ").Append("\r\nON CONFLICT(");
sb.Append(_pgsqlInsert.ToSql()).Append("\r\nON CONFLICT(");
for (var a = 0; a < _columns.Length; a++)
{
if (a > 0) sb.Append(", ");
@ -117,7 +116,7 @@ namespace FreeSql.PostgreSQL.Curd
if (col.Attribute.IsVersion == true)
{
var field = _pgsqlInsert.InternalCommonUtils.QuoteSqlName(col.Attribute.Name);
sb.Append(field).Append(" = _ftb_.").Append(field).Append(" + 1");
sb.Append(field).Append(" = ").Append(_pgsqlInsert.InternalCommonUtils.QuoteSqlName(_pgsqlInsert.InternalTable.DbName)).Append(".").Append(field).Append(" + 1");
}
else if (_pgsqlInsert.InternalIgnore.ContainsKey(col.Attribute.Name))
{