Master Slave bug

This commit is contained in:
sunkaixuan
2019-04-04 21:49:37 +08:00
parent aaf869d1e6
commit d3ac356fb1
3 changed files with 26 additions and 6 deletions

View File

@@ -403,6 +403,8 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = DeleteBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
@@ -410,6 +412,7 @@ namespace SqlSugar
diffModel.Time = this.Context.Ado.SqlExecutionTime;
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
if (this.RemoveCacheFunc != null) {
this.RemoveCacheFunc();
@@ -420,12 +423,15 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = DeleteBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
diffModel.BeforeData = GetDiffTable(sql, parameters);
diffModel.Sql = sql;
diffModel.Parameters = parameters.ToArray();
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
}

View File

@@ -456,6 +456,8 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
this.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = InsertBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
@@ -463,6 +465,7 @@ namespace SqlSugar
diffModel.Time = this.Context.Ado.SqlExecutionTime;
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
if (this.RemoveCacheFunc != null)
{
@@ -473,12 +476,15 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
this.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = InsertBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
diffModel.BeforeData = null;
diffModel.Sql = sql;
diffModel.Parameters = parameters.ToArray();
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
}
private List<DiffLogTableInfo> GetDiffTable(string sql, long? identity)

View File

@@ -411,7 +411,8 @@ namespace SqlSugar
private void PreToSql()
{
UpdateBuilder.PrimaryKeys = GetPrimaryKeys();
if (this.IsWhereColumns) {
if (this.IsWhereColumns)
{
foreach (var pkName in UpdateBuilder.PrimaryKeys)
{
var isContains = this.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName.ToLower()).Contains(pkName.ToLower());
@@ -609,6 +610,8 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
this.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = UpdateBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
@@ -616,8 +619,10 @@ namespace SqlSugar
diffModel.Time = this.Context.Ado.SqlExecutionTime;
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
if (this.RemoveCacheFunc != null) {
if (this.RemoveCacheFunc != null)
{
this.RemoveCacheFunc();
}
}
@@ -626,12 +631,15 @@ namespace SqlSugar
{
if (this.IsEnableDiffLogEvent)
{
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
this.Ado.IsDisableMasterSlaveSeparation = true;
var parameters = UpdateBuilder.Parameters;
if (parameters == null)
parameters = new List<SugarParameter>();
diffModel.BeforeData = GetDiffTable(sql, parameters);
diffModel.Sql = sql;
diffModel.Parameters = parameters.ToArray();
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
}
}