本文整理了Java中org.sonar.db.dialect.Dialect.supportsUpsert()
方法的一些代码示例,展示了Dialect.supportsUpsert()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dialect.supportsUpsert()
方法的具体详情如下:
包路径:org.sonar.db.dialect.Dialect
类名称:Dialect
方法名:supportsUpsert
暂无
代码示例来源:origin: SonarSource/sonarqube
@Override
public void execute(ComputationStep.Context context) {
boolean supportUpsert = dbClient.getDatabase().getDialect().supportsUpsert();
try (DbSession dbSession = dbClient.openSession(supportUpsert)) {
Component root = treeRootHolder.getRoot();
MeasureVisitor visitor = new MeasureVisitor(dbSession, supportUpsert);
new DepthTraversalTypeAwareCrawler(visitor).visit(root);
context.getStatistics().add("insertsOrUpdates", visitor.insertsOrUpdates);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_does_not_update_row_if_values_are_not_changed() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure();
underTest.upsert(db.getSession(), dto);
// update
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(0);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_value_is_changed() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setValue(40.0);
underTest.upsert(db.getSession(), dto);
// update
dto.setValue(50.0);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_variation_is_removed() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setVariation(40.0);
underTest.upsert(db.getSession(), dto);
// update
dto.setVariation(null);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_variation_is_added() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setVariation(null);
underTest.upsert(db.getSession(), dto);
// update
dto.setVariation(40.0);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_value_is_added() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setValue(null);
underTest.upsert(db.getSession(), dto);
// update
dto.setValue(40.0);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_variation_is_changed() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setVariation(40.0);
underTest.upsert(db.getSession(), dto);
// update
dto.setVariation(50.0);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_updates_row_if_value_is_removed() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
LiveMeasureDto dto = newLiveMeasure().setValue(40.0);
underTest.upsert(db.getSession(), dto);
// update
dto.setValue(null);
int count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void upsert_inserts_or_updates_row() {
if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
return;
}
// insert
LiveMeasureDto dto = newLiveMeasure();
int count = underTest.upsert(db.getSession(), dto);
verifyPersisted(dto);
verifyTableSize(1);
assertThat(count).isEqualTo(1);
// update
dto.setValue(dto.getValue() + 1);
dto.setVariation(dto.getVariation() + 10);
dto.setData(dto.getDataAsString() + "_new");
count = underTest.upsert(db.getSession(), dto);
assertThat(count).isEqualTo(1);
verifyPersisted(dto);
verifyTableSize(1);
}
内容来源于网络,如有侵权,请联系作者删除!