mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Support pgsql Conflict nothing
This commit is contained in:
parent
b76945addd
commit
e3f5ba7cca
@ -557,7 +557,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public IInsertable<T> PostgreSQLConflictNothing(string[] columns)
|
||||||
|
{
|
||||||
|
this.InsertBuilder.ConflictNothing = columns;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public IInsertable<T> MySqlIgnore()
|
public IInsertable<T> MySqlIgnore()
|
||||||
{
|
{
|
||||||
this.InsertBuilder.MySqlIgnore = true;
|
this.InsertBuilder.MySqlIgnore = true;
|
||||||
|
@ -133,6 +133,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public bool MySqlIgnore { get; internal set; }
|
public bool MySqlIgnore { get; internal set; }
|
||||||
public bool IsWithAttr { get; internal set; }
|
public bool IsWithAttr { get; internal set; }
|
||||||
|
public string[] ConflictNothing { get; set; }
|
||||||
|
|
||||||
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,7 @@ namespace SqlSugar
|
|||||||
SplitInsertable<T> SplitTable(SplitType splitType);
|
SplitInsertable<T> SplitTable(SplitType splitType);
|
||||||
void AddQueue();
|
void AddQueue();
|
||||||
IInsertable<T> MySqlIgnore();
|
IInsertable<T> MySqlIgnore();
|
||||||
|
IInsertable<T> PostgreSQLConflictNothing(string[] columns);
|
||||||
IInsertable<T> OffIdentity();
|
IInsertable<T> OffIdentity();
|
||||||
IInsertable<T> OffIdentity(bool isSetOn);
|
IInsertable<T> OffIdentity(bool isSetOn);
|
||||||
InsertablePage<T> PageSize(int pageSize);
|
InsertablePage<T> PageSize(int pageSize);
|
||||||
|
@ -49,7 +49,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it =>base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
|
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it =>base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
|
||||||
ActionMinDate();
|
ActionMinDate();
|
||||||
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
return GetIgnoreSql(string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ namespace SqlSugar
|
|||||||
pageIndex++;
|
pageIndex++;
|
||||||
batchInsetrSql.Remove(batchInsetrSql.Length - 1,1).Append("\r\n;\r\n");
|
batchInsetrSql.Remove(batchInsetrSql.Length - 1,1).Append("\r\n;\r\n");
|
||||||
}
|
}
|
||||||
return batchInsetrSql.ToString();
|
return GetIgnoreSql(batchInsetrSql.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +182,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetIgnoreSql(string sql)
|
||||||
|
{
|
||||||
|
if (this.ConflictNothing?.Any() == true)
|
||||||
|
{
|
||||||
|
sql = sql.Replace(";", $" ON CONFLICT ({string.Join(",", this.ConflictNothing)}) DO NOTHING;");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user