Minor fix & clean #32

Merged
flecomte merged 6 commits from minor_fix into master 2022-10-14 23:14:03 +02:00
4 changed files with 6 additions and 6 deletions
Showing only changes of commit 8b9cc22a47 - Show all commits

View File

@@ -14,9 +14,9 @@ data class Paginated<T : EntityI>(
val totalPages: Int = (total.toDouble() / limit.toDouble()).ceil() val totalPages: Int = (total.toDouble() / limit.toDouble()).ceil()
init { init {
if (offset < 0) error("offset must be greather or equal than 0") if (offset < 0) error("offset must be greater or equal than 0")
if (limit < 1) error("limit must be greather or equal than 1") if (limit < 1) error("limit must be greater or equal than 1")
if (total < 0) error("total must be greather or equal than 0") if (total < 0) error("total must be greater or equal than 0")
} }
fun isLastPage(): Boolean = currentPage >= totalPages fun isLastPage(): Boolean = currentPage >= totalPages

View File

@@ -130,7 +130,7 @@ class Migrations private constructor(
enum class Direction { UP, DOWN } enum class Direction { UP, DOWN }
internal class DownMigrationNotDefined(path: String, cause: FileNotFoundException? = null) : internal class DownMigrationNotDefined(path: String, cause: FileNotFoundException? = null) :
Throwable("The file $path whas not found", cause) Throwable("The file $path was not found", cause)
fun addFunction(newDefinition: DefinitionFunction, callback: (Function) -> Unit = {}): Migrations { fun addFunction(newDefinition: DefinitionFunction, callback: (Function) -> Unit = {}): Migrations {
val currentFunction = functions[newDefinition.name] val currentFunction = functions[newDefinition.name]
@@ -174,10 +174,10 @@ class Migrations private constructor(
private fun initDB() { private fun initDB() {
if (!initialized) { if (!initialized) {
this::class.java.classLoader.getResource("sql/migration/createHistoryShema.sql")!!.readText().let { this::class.java.classLoader.getResource("sql/migration/createHistorySchema.sql")!!.readText().let {
connection.sendQuery(it) connection.sendQuery(it)
} }
this::class.java.classLoader.getResource("sql/migration/createFunctionShema.sql")!!.readText().let { this::class.java.classLoader.getResource("sql/migration/createFunctionSchema.sql")!!.readText().let {
connection.sendQuery(it) connection.sendQuery(it)
} }
initialized = true initialized = true