Skip to content

Commit

Permalink
Issue 55 MariaDB Dialect Request
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad-T-Pino authored and komu committed Sep 11, 2024
1 parent 13d1d51 commit 4a7a9b6
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ out
.gradle
dalesbred/src/test/resources/postgresql-connection.properties
dalesbred/src/test/resources/mysql-connection.properties
dalesbred/src/test/resources/mariadb-connection.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencyManagement {
dependency("org.hsqldb:hsqldb:2.4.0")
dependency("com.h2database:h2:1.4.200")
dependency("mysql:mysql-connector-java:8.0.26")
dependency("org.mariadb.jdbc:mariadb-java-client:3.4.1")
dependency("com.oracle.database.jdbc:ojdbc8:21.3.0.0")
dependency("junit:junit:4.13.2")
dependency("ch.qos.logback:logback-core:$logbackVersion")
Expand Down
1 change: 1 addition & 0 deletions dalesbred/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {
testImplementation("org.hsqldb:hsqldb")
testImplementation("com.h2database:h2")
testImplementation("mysql:mysql-connector-java")
testImplementation("org.mariadb.jdbc:mariadb-java-client")
testImplementation("junit:junit")
testImplementation("ch.qos.logback:logback-core")
testImplementation("ch.qos.logback:logback-classic")
Expand Down
4 changes: 4 additions & 0 deletions dalesbred/src/main/java/org/dalesbred/dialect/Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public abstract class Dialect {
log.debug("Automatically detected dialect MySQL.");
return new MySQLDialect();

case "MariaDB":
log.debug("Automatically detected dialect MariaDB.");
return new MariaDBDialect();

case "Oracle":
log.debug("Automatically detected dialect Oracle.");
return new OracleDialect();
Expand Down
29 changes: 29 additions & 0 deletions dalesbred/src/main/java/org/dalesbred/dialect/MariaDBDialect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 Evident Solutions Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.dalesbred.dialect;

/**
* Support for MariaDB.
*/
public class MariaDBDialect extends Dialect {
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ object TestDatabaseProvider {
fun createMySQLConnectionProvider() =
createConnectionProviderFromProperties("mysql-connection.properties")

fun createMariaDBConnectionProvider() =
createConnectionProviderFromProperties("mariadb-connection.properties")

fun createInMemoryHSQLConnectionProvider(): ConnectionProvider =
DriverManagerConnectionProvider("jdbc:hsqldb:.", "sa", "")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Evident Solutions Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.dalesbred.dialect

import org.dalesbred.TestDatabaseProvider
import org.junit.Test
import kotlin.test.assertTrue

class MariaDBDialectTest {

@Test
fun detectMariaDbDialect() {
val dialect = Dialect.detect(TestDatabaseProvider.createMariaDBConnectionProvider())
assertTrue { dialect is MariaDBDialect }
}
}

0 comments on commit 4a7a9b6

Please sign in to comment.