- 恢复 MySql ServerTime = Utc ;#1604 #1624

This commit is contained in:
2881099 2023-09-21 20:08:17 +08:00
parent be6f2fa9c2
commit 9e3b258ffd
5 changed files with 10 additions and 5 deletions

View File

@ -258,9 +258,14 @@ namespace FreeSql.Internal
commonNow = $"{commonNow.TrimEnd('(', ')')}({timeLength})"; commonNow = $"{commonNow.TrimEnd('(', ')')}({timeLength})";
commonNowUtc = $"{commonNowUtc.TrimEnd('(', ')')}({timeLength})"; commonNowUtc = $"{commonNowUtc.TrimEnd('(', ')')}({timeLength})";
} }
//https://github.com/dotnetcore/FreeSql/issues/1604 mysql 不支持默认值 utc_timestamp DDL
if (colattr.ServerTime == DateTimeKind.Local)
col.DbDefaultValue = commonNow;
break;
default:
col.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
break; break;
} }
col.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc; col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
col.DbUpdateValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc; col.DbUpdateValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
} }

View File

@ -68,7 +68,7 @@ namespace FreeSql.Custom.MySql
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}"; public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}"; public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
public override string Now => "now()"; public override string Now => "now()";
public override string NowUtc => "current_timestamp()"; public override string NowUtc => "utc_timestamp()";
public override string QuoteWriteParamterAdapter(Type type, string paramterName) public override string QuoteWriteParamterAdapter(Type type, string paramterName)
{ {

View File

@ -100,7 +100,7 @@ namespace FreeSql.MySql
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}"; public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}"; public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
public override string Now => "now()"; public override string Now => "now()";
public override string NowUtc => "current_timestamp()"; public override string NowUtc => "utc_timestamp()";
public override string QuoteWriteParamterAdapter(Type type, string paramterName) public override string QuoteWriteParamterAdapter(Type type, string paramterName)
{ {

View File

@ -118,7 +118,7 @@ namespace FreeSql.MySql
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}"; public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}"; public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
public override string Now => "now()"; public override string Now => "now()";
public override string NowUtc => "current_timestamp()"; public override string NowUtc => "utc_timestamp()";
public override string QuoteWriteParamterAdapter(Type type, string paramterName) public override string QuoteWriteParamterAdapter(Type type, string paramterName)
{ {

View File

@ -64,7 +64,7 @@ namespace FreeSql.Odbc.MySql
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}"; public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}"; public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
public override string Now => "now()"; public override string Now => "now()";
public override string NowUtc => "current_timestamp()"; public override string NowUtc => "utc_timestamp()";
public override string QuoteWriteParamterAdapter(Type type, string paramterName) public override string QuoteWriteParamterAdapter(Type type, string paramterName)
{ {