mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-21 07:40:57 +08:00
- 补充 pgsql FreeSql.Generator 默认值 uuid_generate_v4() 生成;#2088
This commit is contained in:
@@ -229,7 +229,7 @@ public class RazorModel
|
|||||||
var defval = col.DefaultValue?.Trim();
|
var defval = col.DefaultValue?.Trim();
|
||||||
if (string.IsNullOrEmpty(defval)) return null;
|
if (string.IsNullOrEmpty(defval)) return null;
|
||||||
var cstype = col.CsType.NullableTypeOrThis();
|
var cstype = col.CsType.NullableTypeOrThis();
|
||||||
if (fsql.Ado.DataType == DataType.SqlServer || fsql.Ado.DataType == DataType.OdbcSqlServer)
|
if (fsql.Ado.DataType == DataType.SqlServer || fsql.Ado.DataType == DataType.OdbcSqlServer || fsql.Ado.DataType == DataType.CustomSqlServer)
|
||||||
{
|
{
|
||||||
if (defval.StartsWith("((") && defval.EndsWith("))")) defval = defval.Substring(2, defval.Length - 4);
|
if (defval.StartsWith("((") && defval.EndsWith("))")) defval = defval.Substring(2, defval.Length - 4);
|
||||||
else if (defval.StartsWith("('") && defval.EndsWith("')")) defval = defval.Substring(2, defval.Length - 4).Replace("''", "'");
|
else if (defval.StartsWith("('") && defval.EndsWith("')")) defval = defval.Substring(2, defval.Length - 4).Replace("''", "'");
|
||||||
@@ -240,9 +240,18 @@ public class RazorModel
|
|||||||
if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()";
|
if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()";
|
||||||
if (defval == "NULL") return null;
|
if (defval == "NULL") return null;
|
||||||
}
|
}
|
||||||
|
if (!isInsertValueSql && (fsql.Ado.DataType == DataType.PostgreSQL || fsql.Ado.DataType == DataType.OdbcPostgreSQL || fsql.Ado.DataType == DataType.CustomPostgreSQL ||
|
||||||
|
fsql.Ado.DataType == DataType.KingbaseES ||
|
||||||
|
fsql.Ado.DataType == DataType.ShenTong))
|
||||||
|
{
|
||||||
|
switch (defval)
|
||||||
|
{
|
||||||
|
case "uuid_generate_v4()": return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") ||
|
if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") ||
|
||||||
cstype == typeof(Guid) && defval.StartsWith("'") && defval.EndsWith("'::uuid")
|
cstype == typeof(Guid) && defval.StartsWith("'") && defval.EndsWith("'::uuid")
|
||||||
) && (fsql.Ado.DataType == DataType.PostgreSQL || fsql.Ado.DataType == DataType.OdbcPostgreSQL ||
|
) && (fsql.Ado.DataType == DataType.PostgreSQL || fsql.Ado.DataType == DataType.OdbcPostgreSQL || fsql.Ado.DataType == DataType.CustomPostgreSQL ||
|
||||||
fsql.Ado.DataType == DataType.KingbaseES ||
|
fsql.Ado.DataType == DataType.KingbaseES ||
|
||||||
fsql.Ado.DataType == DataType.ShenTong))
|
fsql.Ado.DataType == DataType.ShenTong))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user