Tabnine Logo
Dialect.getId
Code IndexAdd Tabnine to your IDE (free)

How to use
getId
method
in
org.sonar.db.dialect.Dialect

Best Java code snippets using org.sonar.db.dialect.Dialect.getId (Showing top 20 results out of 315)

origin: SonarSource/sonarqube

private static void appendCollationClause(StringBuilder res, Dialect dialect) {
 if (MySql.ID.equals(dialect.getId())) {
  res.append(" ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin");
 }
}
origin: SonarSource/sonarqube

@Override
public String generateSqlType(Dialect dialect) {
 switch (dialect.getId()) {
  case MsSql.ID:
   return format("NVARCHAR (%d)", columnSize);
  case Oracle.ID:
   return format("VARCHAR2 (%d%s)", columnSize, ignoreOracleUnit ? "" : " CHAR");
  default:
   return format("VARCHAR (%d)", columnSize);
 }
}
origin: SonarSource/sonarqube

private String buildDeleteFromQuery(String tableName, String alias, String whereClause) {
 String dialectId = getDialect().getId();
 if ("mssql".equals(dialectId) || "mysql".equals(dialectId)) {
  return "delete " + alias + " from " + tableName + " as " + alias + " where " + whereClause;
 }
 return "delete from " + tableName + " " + alias + " where " + whereClause;
}
origin: SonarSource/sonarqube

public UpdatePermissionTooLongTemplateKeys(Database db, UuidFactory uuidFactory) {
 super(db);
 this.uuidFactory = uuidFactory;
 if (db.getDialect().getId().equals(MsSql.ID)) {
  lengthFunction = "len";
 } else {
  lengthFunction = "length";
 }
}
origin: SonarSource/sonarqube

public FixMissingQualityProfilesOnOrganizations(Database db, System2 system2, UuidFactory uuidFactory, Configuration configuration) {
 super(db);
 this.system2 = system2;
 this.uuidFactory = uuidFactory;
 this.configuration = configuration;
 if (db.getDialect().getId().equals(MySql.ID) || db.getDialect().getId().equals(MsSql.ID)) {
  as = " AS ";
 } else {
  as = "";
 }
}
origin: SonarSource/sonarqube

@Override
public void start() {
 if (MySql.ID.equals(database.getDialect().getId())) {
  throw new IllegalStateException("MySQL is not supported for Data Center Edition. Please connect to a supported database: Oracle, PostgreSQL, Microsoft SQL Server.");
 }
}
origin: SonarSource/sonarqube

private Stream<String> createOracleAutoIncrementStatements() {
 if (!Oracle.ID.equals(dialect.getId())) {
  return Stream.empty();
 }
 return pkColumnDefs.stream()
  .filter(this::isAutoIncrement)
  .flatMap(columnDef -> of(createSequenceFor(tableName), createOracleTriggerForTable(tableName)));
}
origin: SonarSource/sonarqube

private String createTruncateSql(String table) {
 if (dbClient.getDatabase().getDialect().getId().equals(Oracle.ID)) {
  // truncate operation is needs to lock the table on Oracle. Unfortunately
  // it fails sometimes in our QA environment because table is locked.
  // We never found the root cause (no locks found when displaying them just after
  // receiving the error).
  // Workaround is to use "delete" operation. It does not require lock on table.
  return "DELETE FROM " + table;
 }
 return "TRUNCATE TABLE " + table;
}
origin: SonarSource/sonarqube

public static DatabaseCommands forDialect(Dialect dialect) {
 DatabaseCommands command = ImmutableMap.of(
  org.sonar.db.dialect.H2.ID, H2,
  MsSql.ID, MSSQL,
  MySql.ID, MYSQL,
  Oracle.ID, ORACLE,
  PostgreSql.ID, POSTGRESQL).get(dialect.getId());
 return Preconditions.checkNotNull(command, "Unknown database: " + dialect);
}
origin: SonarSource/sonarqube

private Object toBool(boolean guarded) {
 Dialect dialect = db.database().getDialect();
 if (dialect.getId().equals(Oracle.ID)) {
  return guarded ? 1L : 0L;
 }
 return guarded;
}
origin: SonarSource/sonarqube

private String selectDual() {
 String sql = "SELECT 1";
 if (Oracle.ID.equals(dbTester.database().getDialect().getId())) {
  sql = "SELECT 1 FROM DUAL";
 }
 return sql;
}
origin: SonarSource/sonarqube

@Override
public void execute(Context context) throws SQLException {
 if (getDialect().getId().equals(MsSql.ID)) {
  // this should be handled automatically by DropColumnsBuilder
  dropMssqlConstraints();
 }
 context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_NAME).build());
}
origin: SonarSource/sonarqube

public void start() {
 if (!isDefault && !H2.ID.equals(db.getDialect().getId())) {
  throw new AssumptionViolatedException("Test disabled because it supports only H2");
 }
}
origin: SonarSource/sonarqube

@VisibleForTesting
void installH2() {
 Connection connection = null;
 try (DbSession session = dbClient.openSession(false)) {
  connection = session.getConnection();
  createH2Schema(connection, dbClient.getDatabase().getDialect().getId());
 } finally {
  DbUtils.closeQuietly(connection);
 }
}
origin: SonarSource/sonarqube

@Test
public void generateSqlType_thows_IAE_for_unknown_dialect() {
 Dialect dialect = mock(Dialect.class);
 when(dialect.getId()).thenReturn("AAA");
 expectedException.expect(IllegalArgumentException.class);
 expectedException.expectMessage("Unsupported dialect id AAA");
 underTest.generateSqlType(dialect);
}
origin: SonarSource/sonarqube

 @Test
 public void getHandler_throws_IAE_if_unsupported_db() {
  Dialect unsupportedDialect = mock(Dialect.class);
  when(unsupportedDialect.getId()).thenReturn("foo");

  expectedException.expect(IllegalArgumentException.class);
  expectedException.expectMessage("Database not supported: foo");
  underTest.getHandler(unsupportedDialect);
 }
}
origin: SonarSource/sonarqube

 @Test
 public void generateSqlType_thows_IAE_for_unknown_dialect() {
  Dialect dialect = mock(Dialect.class);
  when(dialect.getId()).thenReturn("AAA");

  expectedException.expect(IllegalArgumentException.class);
  expectedException.expectMessage("Unsupported dialect id AAA");

  underTest.generateSqlType(dialect);
 }
}
origin: SonarSource/sonarqube

@Before
public void disableIfNotH2() {
 // TODO dbTester.selectFirst() returns keys with different case
 // depending on target db (lower-case for MySQL but upper-case for H2).
 // It has to be fixed in order to reactive this test for all dbs.
 assumeTrue(dbTester.database().getDialect().getId().equals(H2.ID));
}
origin: SonarSource/sonarqube

@Test
public void shouldGuessDialectFromUrl() {
 Settings settings = new MapSettings();
 settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
 DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
 database.initSettings();
 assertThat(database.getDialect().getId()).isEqualTo(PostgreSql.ID);
}
origin: SonarSource/sonarqube

 @Test
 public void fail_with_UOE_to_generate_sql_type_when_unknown_dialect() {
  thrown.expect(UnsupportedOperationException.class);
  thrown.expectMessage("Unknown dialect 'unknown'");

  TinyIntColumnDef def = new TinyIntColumnDef.Builder()
   .setColumnName("foo")
   .setIsNullable(true)
   .build();

  Dialect dialect = mock(Dialect.class);
  when(dialect.getId()).thenReturn("unknown");
  def.generateSqlType(dialect);
 }
}
org.sonar.db.dialectDialectgetId

Popular methods of Dialect

  • getFalseSqlValue
  • getScrollDefaultFetchSize
    Fetch size to be used when scrolling large result sets.
  • getTrueSqlValue
  • getConnectionInitStatements
  • getDefaultDriverClassName
  • getValidationQuery
    Query used to validate the jdbc connection.
  • supportsMigration
    Indicates whether DB migration can be perform on the DB vendor implementation associated with the cu
  • getScrollSingleRowFetchSize
    Fetch size to scroll one row at a time. It sounds strange because obviously value is 1 in most cases
  • init
    This method is called when connecting for the first time to the database.
  • matchesJdbcUrl
    Used to autodetect dialect from connection URL
  • supportsUpsert
  • getSqlFromDual
  • supportsUpsert,
  • getSqlFromDual,
  • matchesJdbcURL

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now