空格导致的一次线上事故

 

发布表单模型【check form and publish】的时候报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=update_time,asin)' at line 1

导致发布失败。

症状:

----------xxxxx----------
2024-11-05 17:08:56
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=update_time,asin)' at line 1
at Instrument.DBS.DbHelper.ExecuteNonQuery(String sql, MySqlParameter[] sqlparemeter)
at SassServer.etc.InstrumentX.auto_check_table_index_with_code(String tabid)
at SassServer.Controllers.EngineController.publish_form_and_create_database_table(String coulmn, String tablename, String tabid, String prefixv, String tabledesc, Dictionary`2 dictionary)
at SassServer.Controllers.EngineController.operate(Dictionary`2 dictionary)
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN7TF5N07JS8", Request id "0HN7TF5N07JS8:00000001": An unhandled exception was thrown by the application.
MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

 

原因分析:

near '=update_time,asin)' at line 1--》这里是自动创建index,tmd竟然有一个等于=符号,找到对应的程序里面创建index的代码,

1
2
3
4
5
6
7
8
9
10
11
if (x.trim_all().StartsWith("sort="))
      {
           
          var arrKeys = x.Replace("sort=", "").Replace("\"", "").Replace(";", "").Split(',');
          foreach (var xKey in arrKeys)
          {
              string key = xKey.Replace("desc", "").Replace("asc", "").trim_all();
              if (key.is_not_null_or_empty())
                  hashSet.Add(key.ToLower());
          }
      }

  

if判断条件是ok的,那就是需要把

1
var arrKeys = x.Replace("sort=", "").Replace("\"", "").Replace(";", "").Split(',');<br><br>改为:<br><br>var arrKeys = x.trim_all().Replace("sort=", "").Replace("\"", "").Replace(";", "").Split(',');<br><br>还有就是把 sort = "update_time desc"; 直接改为:sort="update_time desc";-- 不包含空格即可。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

done

 

posted @   liskov_design  阅读(13)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
历史上的今天:
2017-11-06 给接口做数据加密操作
点击右上角即可分享
微信分享提示