Skip to content

Commit

Permalink
chore: Change dialect names in DialectNameProvider to be more display…
Browse files Browse the repository at this point in the history
…-friendly
  • Loading branch information
joc-a committed Sep 21, 2023
1 parent 86bf04c commit 4827c99
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions exposed-core/api/exposed-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -3556,10 +3556,13 @@ public final class org/jetbrains/exposed/sql/vendors/OracleDialect$Companion : o
public class org/jetbrains/exposed/sql/vendors/PostgreSQLDialect : org/jetbrains/exposed/sql/vendors/VendorDialect {
public static final field Companion Lorg/jetbrains/exposed/sql/vendors/PostgreSQLDialect$Companion;
public fun <init> ()V
public fun <init> (Ljava/lang/String;)V
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun createDatabase (Ljava/lang/String;)Ljava/lang/String;
protected fun createIndexWithType (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
public fun dropDatabase (Ljava/lang/String;)Ljava/lang/String;
public fun dropIndex (Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/lang/String;
public fun getName ()Ljava/lang/String;
public fun getRequiresAutoCommitOnCreateDrop ()Z
public fun getSupportsOrderByNullsFirstLast ()Z
public fun getSupportsWindowFrameGroupsMode ()Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Database private constructor(
}

fun registerDialect(prefix: String, dialect: () -> DatabaseDialect) {
dialects[prefix] = dialect
dialects[prefix.lowercase()] = dialect
}

fun registerJdbcDriver(prefix: String, driverClassName: String, dialect: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ open class H2Dialect : VendorDialect(dialectName, H2DataTypeProvider, H2Function
private var delegatedDialect: DatabaseDialect? = null

private fun resolveDelegatedDialect(): DatabaseDialect? {
return delegatedDialect ?: delegatedDialectNameProvider?.dialectName?.let {
return delegatedDialect ?: delegatedDialectNameProvider?.dialectName?.lowercase()?.let {
val dialect = Database.dialects[it]?.invoke() ?: error("Can't resolve dialect for $it")
delegatedDialect = dialect
dialect
Expand Down Expand Up @@ -269,7 +269,7 @@ open class H2Dialect : VendorDialect(dialectName, H2DataTypeProvider, H2Function

override fun dropDatabase(name: String) = "DROP SCHEMA IF EXISTS ${name.inProperCase()}"

companion object : DialectNameProvider("h2")
companion object : DialectNameProvider("H2")
}

val DatabaseDialect.h2Mode: H2Dialect.H2CompatibilityMode? get() = (this as? H2Dialect)?.h2Mode
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ class MariaDBDialect : MysqlDialect() {
return super.createIndex(index)
}

companion object : DialectNameProvider("mariadb")
companion object : DialectNameProvider("MariaDB")
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,5 @@ open class MysqlDialect : VendorDialect(dialectName, MysqlDataTypeProvider, Mysq
}
}

companion object : DialectNameProvider("mysql")
companion object : DialectNameProvider("MySQL")
}
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,5 @@ open class OracleDialect : VendorDialect(dialectName, OracleDataTypeProvider, Or
}
}

companion object : DialectNameProvider("oracle")
companion object : DialectNameProvider("Oracle")
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ internal object PostgreSQLFunctionProvider : FunctionProvider() {
/**
* PostgreSQL dialect implementation.
*/
open class PostgreSQLDialect : VendorDialect(dialectName, PostgreSQLDataTypeProvider, PostgreSQLFunctionProvider) {
open class PostgreSQLDialect(override val name: String = dialectName) : VendorDialect(dialectName, PostgreSQLDataTypeProvider, PostgreSQLFunctionProvider) {
override val supportsOrderByNullsFirstLast: Boolean = true

override val requiresAutoCommitOnCreateDrop: Boolean = true
Expand Down Expand Up @@ -342,16 +342,16 @@ open class PostgreSQLDialect : VendorDialect(dialectName, PostgreSQLDataTypeProv
}
}

companion object : DialectNameProvider("postgresql")
companion object : DialectNameProvider("PostgreSQL")
}

/**
* PostgreSQL dialect implementation using the pgjdbc-ng jdbc driver.
*
* The driver accepts basic URLs in the following format : jdbc:pgsql://localhost:5432/db
*/
open class PostgreSQLNGDialect : PostgreSQLDialect() {
open class PostgreSQLNGDialect : PostgreSQLDialect(dialectName) {
override val requiresAutoCommitOnCreateDrop: Boolean = true

companion object : DialectNameProvider("pgsql")
companion object : DialectNameProvider("PostgreSQLNG")
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ open class SQLServerDialect : VendorDialect(dialectName, SQLServerDataTypeProvid
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15#arguments
override val likePatternSpecialChars = sqlServerLikePatternSpecialChars

companion object : DialectNameProvider("sqlserver") {
companion object : DialectNameProvider("SQLServer") {
private val sqlServerLikePatternSpecialChars = mapOf('%' to null, '_' to null, '[' to ']')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ open class SQLiteDialect : VendorDialect(dialectName, SQLiteDataTypeProvider, SQ

override fun dropDatabase(name: String) = "DETACH DATABASE ${name.inProperCase()}"

companion object : DialectNameProvider("sqlite") {
companion object : DialectNameProvider("SQLite") {
val ENABLE_UPDATE_DELETE_LIMIT by lazy {
var conn: Connection? = null
var stmt: Statement? = null
Expand Down

0 comments on commit 4827c99

Please sign in to comment.