Skip to content

Commit

Permalink
Merge pull request #11 from hossain-khan/feature/copilot-mods
Browse files Browse the repository at this point in the history
Code modification using Copilot
  • Loading branch information
hossain-khan authored Nov 18, 2023
2 parents 89f32ce + 9b4effa commit fbc79ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions src/main/kotlin/dev/hossain/postgresqldelight/SportsRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ class SportsRepository constructor(
SportsDatabase.Schema.create(driver)
}


/**
* Creates a [DataSource] using [HikariDataSource].
* @param appConfig the [AppConfig] required to create the [DataSource].
*/
private fun getDataSource(appConfig: AppConfig): DataSource {
val hikariConfig = HikariConfig()
// https://jdbc.postgresql.org/documentation/use/
hikariConfig.setJdbcUrl("jdbc:postgresql://${appConfig.dbHost}/${appConfig.dbName}")
hikariConfig.driverClassName = "org.postgresql.Driver"
hikariConfig.username = appConfig.dbUsername
hikariConfig.password = appConfig.dbPassword

return HikariDataSource(hikariConfig)
val config = HikariConfig().apply {
jdbcUrl = "jdbc:postgresql://${appConfig.dbHost}/${appConfig.dbName}"
driverClassName = "org.postgresql.Driver"
username = appConfig.dbUsername
password = appConfig.dbPassword
maximumPoolSize = 3
isAutoCommit = false
transactionIsolation = "TRANSACTION_REPEATABLE_READ"
validate()
}
return HikariDataSource(config)
}
}

0 comments on commit fbc79ae

Please sign in to comment.