mysql 无实体插入报错,是不是因为表字段中有特殊字符串导致,麻烦帮忙看一下呢 返回

SqlSugar 处理完成
9 260

热忱回答9

  • 0 回复
  • 图片.png

    修改了链接字符加上了CharSet=utf8mb4;Allow User Variables=True;

    不应该是字符集的问题吧我其他的表是可以插入的

    问题表结构:


    SET NAMES utf8mb4;
    SET FOREIGN_KEY_CHECKS = 0;

    -- ----------------------------
    -- Table structure for result_road
    -- ----------------------------
    DROP TABLE IF EXISTS `result_road`;
    CREATE TABLE `result_road`  (
      `VIN` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
      `Date` datetime(0) NULL DEFAULT NULL,
      `DMS_AUTO_DEVICE_ID` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DMS_AUTO_UPDATE_TIME` datetime(0) NULL DEFAULT NULL,
      `ABSValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `AccelerationValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ALLValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `BrakeDistanceFL` double NULL DEFAULT NULL,
      `BrakeDistanceFLValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `BrakeDistanceFR` double NULL DEFAULT NULL,
      `BrakeDistanceFRValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `BrakeDistanceRL` double NULL DEFAULT NULL,
      `BrakeDistanceRLValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `BrakeDistanceRR` double NULL DEFAULT NULL,
      `BrakeDistanceRRValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `BrakeDistanceValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DECREASE_FL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DECREASE_FR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DECREASE_RL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DECREASE_RR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DragForceFL` bigint(0) NULL DEFAULT NULL,
      `DragForceFLPercentage` double NULL DEFAULT NULL,
      `DragForceFR` bigint(0) NULL DEFAULT NULL,
      `DragForceFRPercentage` double NULL DEFAULT NULL,
      `DragForceRL` bigint(0) NULL DEFAULT NULL,
      `DragForceRLPercentage` double NULL DEFAULT NULL,
      `DragForceRR` bigint(0) NULL DEFAULT NULL,
      `DragForceRRPercentage` double NULL DEFAULT NULL,
      `DragForceValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DragForceValuationFL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DragForceValuationFR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DragForceValuationRL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DragForceValuationRR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ForceDiffFL` double NULL DEFAULT NULL,
      `ForceDiffFR` double NULL DEFAULT NULL,
      `ForceDiffFront` double NULL DEFAULT NULL,
      `ForceDiffRear` double NULL DEFAULT NULL,
      `ForceDiffRL` double NULL DEFAULT NULL,
      `ForceDiffRR` double NULL DEFAULT NULL,
      `ForceFL` double NULL DEFAULT NULL,
      `ForceFL/FR` double NULL DEFAULT NULL,
      `ForceFL/FRValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ForceFR` double NULL DEFAULT NULL,
      `ForceFrontTotalValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ForceRearTotalValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ForceRL` double NULL DEFAULT NULL,
      `ForceRL/RR` double NULL DEFAULT NULL,
      `ForceRL/RRValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ForceRR` double NULL DEFAULT NULL,
      `ForceTotal` double NULL DEFAULT NULL,
      `ForceTotalPercentage` double NULL DEFAULT NULL,
      `FrontAxleValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `FrontForceMax` double NULL DEFAULT NULL,
      `FrontTotal` double NULL DEFAULT NULL,
      `FrontTotalPercentage` double NULL DEFAULT NULL,
      `HandBrakeValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `HandForceHB` bigint(0) NULL DEFAULT NULL,
      `HandForceHBPercentage` double NULL DEFAULT NULL,
      `HandForceRL` bigint(0) NULL DEFAULT NULL,
      `HandForceRR` bigint(0) NULL DEFAULT NULL,
      `Horn` double NULL DEFAULT NULL,
      `HornValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `ID` bigint(0) NULL DEFAULT NULL,
      `INCREASE_FL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `INCREASE_FR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `INCREASE_RL` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `INCREASE_RR` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `LastUpload` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `RearAxleValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `RearForceMax` double NULL DEFAULT NULL,
      `RearRoadValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `RearTotal` double NULL DEFAULT NULL,
      `RearTotalPercentage` double NULL DEFAULT NULL,
      `Speed` double NULL DEFAULT NULL,
      `SpeedValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `TotalBrakeValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `TotalVehicleValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `DMS_AUTO_UPDATE_FLAG` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `PK_DMS_AUTO_INDEX_Result_Road` bigint(0) NOT NULL,
      `ForceDECREASE_FL` double NULL DEFAULT NULL,
      `ForceDECREASE_FR` double NULL DEFAULT NULL,
      `ForceDECREASE_RL` double NULL DEFAULT NULL,
      `ForceDECREASE_RR` double NULL DEFAULT NULL,
      `ForceINCREASE_FL` double NULL DEFAULT NULL,
      `ForceINCREASE_FR` double NULL DEFAULT NULL,
      `ForceINCREASE_RL` double NULL DEFAULT NULL,
      `ForceINCREASE_RR` double NULL DEFAULT NULL,
      `WSS_FL_Max_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_FL_Max_Value` double NULL DEFAULT NULL,
      `WSS_FL_Min_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_FL_Min_Value` double NULL DEFAULT NULL,
      `WSS_FR_Max_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_FR_Max_Value` double NULL DEFAULT NULL,
      `WSS_FR_Min_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_FR_Min_Value` double NULL DEFAULT NULL,
      `WSS_RL_Max_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_RL_Max_Value` double NULL DEFAULT NULL,
      `WSS_RL_Min_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_RL_Min_Value` double NULL DEFAULT NULL,
      `WSS_RR_Max_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_RR_Max_Value` double NULL DEFAULT NULL,
      `WSS_RR_Min_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `WSS_RR_Min_Value` double NULL DEFAULT NULL,
      `WSS_ValStr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `iBoosterPressuremin` double NULL DEFAULT NULL,
      `iBoosterValuation` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `SpeedDiff` double NULL DEFAULT NULL,
      `DMS_AUTO_GUID` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `Uploaded2Seres` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
      `Uploaded2SeresTime` datetime(0) NULL DEFAULT NULL
    ) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;

    SET FOREIGN_KEY_CHECKS = 1;

    0 回复
  • @fate sta:在帮忙看一下呢

    0 回复
  • image.png


    这个错是 FR_46这列不存在。不是乱码

    0 回复
  • @fate sta:  FR_46是Allow User Variables=True;这加入后@ForceFL/FR_46这个参数应该被识别为了两个字段图片.png是不是这个字段里面包含了/这个字符导致的?

    0 回复
  • @fate sta:可以帮运行跑一下看一下呢?

    0 回复
  • 我看一下吧

    0 回复
  • db.Aop.OnExecutingChangeSql = (sql, pars) =>
    {
        foreach (var item in pars)
        {
            if (item.ParameterName.Contains("/")) 
            {
                var newName=item.ParameterName.Replace("/", "_");
                var oldName = item.ParameterName;
                item.ParameterName =newName ;
                sql=sql.Replace(oldName, newName);
            }
        }
        return new KeyValuePair<string, SugarParameter[]>(sql,pars);
    };

    AOP处理一下参数名

    0 回复
  • @xxx/yyy 这样的名字就报错了 ,ORM如果验证这个名字会有一点性能损耗,所以你自个替换一下

    0 回复