Closed nuaabuaa07 closed 5 years ago
是用replace into 操作
我使用的是core模块里面的测试案例SideSqlExecTest.class提交测试的。测试中发现。 1.当mysql中设置了主键,使用“insert into”操作,会覆盖更新mysql表里相应主键的条目。 2.无论mysql中设置主键还是取消主键,使用“replace into”操作都会报错。 sql语句如下: replace into MyResult select count(1) as id, MyTable.name from MyTable group by MyTable.name;
错误提示如下:
语法你只能写insert into,但是底层mysql的操作是replace into 操作
明白了。
最好能允许 用户自己填写语句;
如: replace into table select '${0}', ifnull((select cnt from table where id = '${0}'),0)+{1}
例如: https://harbby.github.io/project/sylph/zh-cn/docs/intro/quickstart.html#demo1
这样能带给使用者 非常多的灵活性
可以考虑
结果表 的声明需要加些特定配置吗
项目目前支持输出到外部mysql表,使用replace操作吗?比如主键冲突时直接覆盖更新。我测试试,貌似只支持insert into 操作。