test_that("jdbc_class_to_dialect maps known databases", {
  expect_s3_class(
    jdbc_class_to_dialect("org.postgresql.jdbc.PgConnection"),
    "sql_dialect_postgres"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.mariadb.jdbc.Connection"),
    "sql_dialect_mariadb"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.mysql.cj.jdbc.ConnectionImpl"),
    "sql_dialect_mysql"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.sqlite.jdbc4.JDBC4Connection"),
    "sql_dialect_sqlite"
  )
  expect_s3_class(
    jdbc_class_to_dialect("oracle.jdbc.driver.T4CConnection"),
    "sql_dialect_oracle"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.microsoft.sqlserver.jdbc.SQLServerConnection"),
    "sql_dialect_mssql"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.ibm.db2.jcc.DB2Connection"),
    "sql_dialect_db2"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.sap.db.jdbc.HanaConnection"),
    "sql_dialect_hana"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.teradata.jdbc.TeraConnection"),
    "sql_dialect_teradata"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.apache.hive.jdbc.HiveConnection"),
    "sql_dialect_hive"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.apache.spark.sql.SparkSession"),
    "sql_dialect_spark_sql"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.simba.spark.jdbc.SparkConnection"),
    "sql_dialect_spark_sql"
  )
  expect_s3_class(
    jdbc_class_to_dialect("net.snowflake.client.jdbc.SnowflakeConnection"),
    "sql_dialect_snowflake"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.cloudera.impala.jdbc.ImpalaConnection"),
    "sql_dialect_impala"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.simba.impala.jdbc.ImpalaConnection"),
    "sql_dialect_impala"
  )
  expect_s3_class(
    jdbc_class_to_dialect("com.amazon.redshift.jdbc.RedshiftConnection"),
    "sql_dialect_redshift"
  )
})

test_that("jdbc_class_to_dialect falls back to ODBC for unknown databases", {
  expect_s3_class(
    jdbc_class_to_dialect("com.unknown.jdbc.Connection"),
    "sql_dialect_odbc"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.h2.jdbc.JdbcConnection"),
    "sql_dialect_odbc"
  )
  expect_s3_class(
    jdbc_class_to_dialect("org.hsqldb.jdbc.JDBCConnection"),
    "sql_dialect_odbc"
  )
})
