You are currently viewing Thoughts aloud about Exposed

Thoughts aloud about Exposed

Text below is my humble opinion. But I want to hear an opposite opinion.

IMHO Exposed is poorly designed library. If you look at the example in its readme, you can see database connection, transaction and queries are implicitly related to one another:

// Where is database connection stored? Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver", user = "root", password = "") // How does transaction chose a database connection? transaction { // An implicit use of transaction SchemaUtils.create (Cities, Users) // It is a runtime error if we try to execute query outside of transaction val saintPetersburgId = Cities.insert { it[name] = "St. Petersburg" } get Cities.id } 

There are a lot of global and thread local variables. All the expressions implicitly depend on the current transaction (they all need a dialect to be compiled).

Also I think some issues is a result of this design. For example: https://github.com/JetBrains/Exposed/issues/726

As a python developer I get upset when I see this. Want someone to implement SQLAlchemy in Kotlin )))

PS: The Zen of Python:

  • Explicit is better than implicit.

submitted by /u/anti-socialisto
[link] [comments]