Tables.initialize tries to create tables even if the connection was unsuccesful
mirelon opened this issue · comments
Michal Kovac commented
...
[DEBUG] [03/03/2016 16:17:50.477] [main] activerecord - dev.idleConnectionTestPeriod -> (not found)
[DEBUG] [03/03/2016 16:22:05.439] [main] activerecord - create table [table_name] (
...
Exception in thread "main" java.lang.reflect.InvocationTargetException
...
Caused by: java.sql.SQLException: Unable to open a test connection to the given database.
...
at com.github.aselab.activerecord.ActiveRecordTables$class.initialize(ActiveRecordTables.scala:113)
...
Caused by: java.net.ConnectException: Connection timed out
I think the method isCreated
should not return Boolean, but 3 values:
- tables are created
- tables are not created, create them
- could not check whether they are created, do not try to create them
There is (https://github.com/aselab/scala-activerecord/blob/master/activerecord/src/main/scala/ActiveRecordTables.scala#L97) this code:
} catch {
case e: Throwable => false
}
Maybe various exceptions should be processed differently.
scala-activerecord version 0.3.1