Db.insertBatchWithFirstRowColumns方法自动填充主键错误
TianXinX opened this issue · comments
TX7899 commented
Michael Yang commented
麻烦给出使用的代码,以及错误信息。
TX7899 commented
问题一:不能自动填充主键字段
建表语句
CREATE TABLE test(
id VARCHAR(20) PRIMARY KEY,
name VARCHAR(20),
age INTEGER
);
测试代码
@SpringBootTest
public class DbRowTest {
@Test
public void testDbInsertBatchWithFirstRowColumns() {
List<Row> rows = new ArrayList<>();
Row row1 = Row.ofKey(RowKey.SNOW_FLAKE_ID);
row1.put("name", "张三");
row1.put("age", 20);
rows.add(row1);
Row row2 = Row.ofKey(RowKey.SNOW_FLAKE_ID);
row2.put("age", 30);
row2.put("name", "李四");
rows.add(row2);
Db.insertBatchWithFirstRowColumns("test", rows);
}
}
错误信息
问题二:列顺序没有与第一条保持一致
测试代码
@SpringBootTest
public class DbRowTest {
@Test
public void testDbInsertBatchWithFirstRowColumns() {
List<Row> rows = new ArrayList<>();
Row row1 = new Row();
row1.put("id", "1");
row1.put("name", "张三");
row1.put("age", 20);
rows.add(row1);
Row row2 = new Row();
row2.put("age", 30);
row2.put("id", "2");
row2.put("name", "李四");
rows.add(row2);
Db.insertBatchWithFirstRowColumns("test", rows);
}
}