Browse Source

Apewer-6.0.14:修正了 Json.Parse 的 NULL 引用问题;修正生成 MySQL 的 Insert 语句字段报错问题。

dev
Elivo 5 years ago
parent
commit
946e0c2134
  1. 2
      Apewer/Apewer.csproj
  2. 3
      Apewer/Json.cs
  3. 58
      Apewer/Source/MySql.cs
  4. 4
      Apewer/_ChangeLog.md

2
Apewer/Apewer.csproj

@ -7,7 +7,7 @@
<AssemblyName>Apewer</AssemblyName> <AssemblyName>Apewer</AssemblyName>
<PackageId>Apewer</PackageId> <PackageId>Apewer</PackageId>
<Title>Apewer</Title> <Title>Apewer</Title>
<Version>6.0.13</Version> <Version>6.0.14</Version>
</PropertyGroup> </PropertyGroup>
<!-- Info --> <!-- Info -->

3
Apewer/Json.cs

@ -1277,6 +1277,8 @@ namespace Apewer
} }
} }
if (value != null)
{
// 处理 Type 对象。 // 处理 Type 对象。
if (value.GetType().Equals(typeof(Type)) && (previous.Count > 2)) if (value.GetType().Equals(typeof(Type)) && (previous.Count > 2))
{ {
@ -1288,6 +1290,7 @@ namespace Apewer
{ {
value = ((Assembly)value).FullName; value = ((Assembly)value).FullName;
} }
}
if (value == null) { json.AddItem(); } if (value == null) { json.AddItem(); }
else if (value is DateTime) { json.SetProperty(field, value.ToString()); } else if (value is DateTime) { json.SetProperty(field, value.ToString()); }

58
Apewer/Source/MySql.cs

@ -738,30 +738,52 @@ namespace Apewer.Source
return columns; return columns;
} }
private static string GenerateInsertStatement(string argTable, List<string> argColumns) private static string GenerateInsertStatement(string table, List<string> columns)
{ {
var result = TextUtility.EmptyString; var sql = TextUtility.EmptyString;
var table = TextUtility.AntiInject(argTable, 255); var tn = TextUtility.AntiInject(table, 255);
if (argColumns != null && !TextUtility.IsBlank(table)) if (columns != null && !TextUtility.IsBlank(tn))
{ {
var count = argColumns.Count; var count = columns.Count;
var names = new List<string>(count); var names = new List<string>(count);
var values = new List<string>(count); var values = new List<string>(count);
foreach (var column in argColumns) foreach (var column in columns)
{
//names.Add(TextGenerator.Merge("[", column, "]"));
names.Add(TextUtility.Merge(column));
values.Add("@" + column);
}
var text = new StringBuilder();
if (count > 0)
{ {
text.Append("insert into `", table, "`(", string.Join(", ", names), ") "); if (string.IsNullOrEmpty(column)) continue;
text.Append("values(", string.Join(", ", values), "); "); names.Add($"`{column}`");
} values.Add($"@{column}");
result = text.ToString(); }
var ns = string.Join(", ", names);
var vs = string.Join(", ", values);
sql = $"insert into `{tn}` ({ns}) values ({vs}); ";
// var sb = new StringBuilder();
// if (columns.Count > 0)
// {
// sb.Append("insert into `");
// sb.Append(tn);
// sb.Append("` (");
// for (var i = 0; i < columns.Count; i++)
// {
// if (i > 0) sb.Append(", ");
// sb.Append("`");
// sb.Append(columns[i]);
// sb.Append("`");
// }
// sb.Append(") values (");
// for (var i = 0; i < columns.Count; i++)
// {
// if (i > 0) sb.Append(", ");
// sb.Append("@");
// sb.Append(columns[i]);
// }
// sb.Append("); ");
// }
// sql = sb.ToString();
} }
return result; return sql;
} }
private static string GenerateUpdateStatement(TableStructure structure, string key, List<string> columns) private static string GenerateUpdateStatement(TableStructure structure, string key, List<string> columns)

4
Apewer/_ChangeLog.md

@ -5,6 +5,10 @@
### 最新提交 ### 最新提交
### 6.0.14
- 修正了 Json.Parse 的 NULL 引用问题;
- 修正了生成 MySQL 的 Insert 语句字段报错问题。
### 6.0.13 ### 6.0.13
- 从文本转换到 Single、Double 和 Decimal,在转换前将自动修剪; - 从文本转换到 Single、Double 和 Decimal,在转换前将自动修剪;
- 不再强制要求在启动 Kestrel 前调用 SetKestrelEntries。 - 不再强制要求在启动 Kestrel 前调用 SetKestrelEntries。

Loading…
Cancel
Save