nilTheDev
10/21/2021, 4:35 PMsubashz
10/26/2021, 4:33 PMEmery Tanghanwaye
10/26/2021, 11:34 PMdave08
10/28/2021, 11:31 AMspand
10/29/2021, 7:11 AMbooleanParam()
and booleanLiteral()
? I can look at the code but the different use cases escape me. They seem extremely similarthan_
11/01/2021, 1:23 PMobject TransactionTestTable: LongIdTable(){
val foo = integer("foo").check { it greater 0 }
}
when I do
newSuspendedTransaction {
TransactionTestTable.insert { it[foo] = 1 }
throw IllegalStateException("FAIL")
}
the transaction performs a rollback correctly and nothing gets inserted into the table
but when I do
newSuspendedTransaction {
TransactionTestTable.insert { it[foo] = 1 }
TransactionTestTable.insert { it[foo] = 0 }
}
the transaction still fails, but the first value gets inserted in the database.
Is this intentional or a bug?nordiauwu
11/02/2021, 12:16 PMJeff
11/03/2021, 1:08 PMHugo Jonker
11/09/2021, 2:04 PMdave08
11/10/2021, 3:06 PMcrummy
11/10/2021, 8:57 PMdave08
11/11/2021, 4:23 PMcom.h2database:h2:{require 1.4.200; reject _} -> 1.4.200
...?Attila Nagy
11/15/2021, 8:46 PMAlexander Weickmann
12/02/2021, 2:14 PMfun connect(getNewConnection: () -> Connection, ...)
We use ktor as our http backend and now the only problem is how we can get the auth information from ktor into this lambda.
We are able to store the required info in the pipeline context of ktor. So what we specifically try right now is to get PipelineContext data into the getNewConnection lambda:
Database.connect(getNewConnection = {
val jdbcUrl = "jdbc:${DbConfig.jdbcProtocol}://${DbConfig.hostname}:${DbConfig.port}/${DbConfig.database}"
val user = "" // TODO how to get the data from ktor pipeline context into this lambda here?
val password = "" // TODO how to get the data from ktor pipeline context into this lambda here?
DriverManager.getConnection(jdbcUrl, user, password)
})
Has somebody tried such a thing already? We need to somehow make Exposed aware of the ktor pipeline context, so we can set the credentials for the database based on the rest call at hand. Any tips or suggestions at all would be very much appreciated.Osmium
12/03/2021, 2:23 PMjavax.sql.Cnnection
implementation supports only small subset of interface features.
So, I wrote my own ExposedConnection
implementatiion, but I don't know how to pass it in Database
.
In other words, how can I reimplement org.jetbrains.exposed.sql.statements.jdbc.JdbcConnectionImpl
and pass it in Database.connect()
?hfhbd
12/07/2021, 2:59 PMPeter Scardera
12/10/2021, 4:41 PMFilip Lastic
12/15/2021, 9:50 AMfun getDefaultIsolationLevel(db: Database): Int =
when (db.vendor) {
SQLiteDialect.dialectName -> Connection.TRANSACTION_SERIALIZABLE
OracleDialect.dialectName -> Connection.TRANSACTION_READ_COMMITTED
PostgreSQLDialect.dialectName -> Connection.TRANSACTION_READ_COMMITTED
PostgreSQLNGDialect.dialectName -> Connection.TRANSACTION_READ_COMMITTED
else -> DEFAULT_ISOLATION_LEVEL
}
const val DEFAULT_ISOLATION_LEVEL = Connection.TRANSACTION_REPEATABLE_READ
Марк Эпштейн
12/17/2021, 5:17 PMselect * from (select "1" as id) as idSource left join demo on idSource.id=demo.ID ...<other 10 tables where this id could exist>.
Write via full join and 10 conditions demo.id ="1" or demo 2.id ="1" he doesn't really want to.
Maybe someone knows how (select "1" as id) as idSource can be written in exposed?
join function accept ColumnSet as parameter. ColumnSet has Columns which refers to Table. But idSource is not table here.
@tapac, Bogdan Panchenko gave me advise tag you under the question.Deji
12/19/2021, 1:39 AMobject Profile : IntIdTable("profile", "id") {
val externalId: Column<String> = varchar("external_id",
255).uniqueIndex("external_profile_external_id_uindex")
val profileUrl: Column<String?> = varchar("profile_url",
255).uniqueIndex("external_profile_profile_url_uindex").nullable()
val imageUrl: Column<String?> = varchar("image_url", 255).nullable()
val uri: Column<String> = varchar("uri", 255).uniqueIndex("external_profile_uri_uindex")
}
object User : IntIdTable("user", "id") {
val username: Column<String> = varchar("username",
20).uniqueIndex("internal_user_username_uindex")
val email: Column<String> = varchar("email",
255).uniqueIndex("internal_user_email_uindex")
val displayName: Column<String?> = varchar("display_name", 255).nullable()
val externalProfileId: Column<Int> =
integer("profile_id").references(Profile.id).uniqueIndex("internal_user_external_profile_id_uindex")
}
val profile = Profile.insert {
it[externalId] = "externalId"
it[profileUrl] = "profileUrl"
it[imageUrl] = "imageUrl"
it[uri] = "uri"
}
val user = User.insert {
it[username] = "username"
it[email] = "email"
it[displayName] = "displauName"
it[externalProfileId] = profile[id] // <--- this line fails to compile
}
I cant set the externalProfileId foreign key to the ID from the new profile created. is there a better way to do this? Thanks!Hugo Jonker
12/20/2021, 8:09 AMJames Myers
12/21/2021, 3:01 PMval updatedAt = datetime("updated_at").defaultExpression(CurrentDateTime())
I was looking at the following chunk for using the EntityHook
and it wasn’t clear how to leverage the CurrentDateTime
here as well:
EntityHook.subscribe { action ->
if (action.changeType == EntityChangeType.Updated) {
action.toEntity(this)?.updatedAt = LocalDateTime.now(Clock.systemUTC())
}
}
I’ve tried looking through the code/docs but wasn’t able to find an example of how to do this properly. Is there something obvious that I’m missing here, or do these two not work very well together. Any help would be appreciated. Thanks!Khurram Malik
12/31/2021, 8:45 PM/**
* Identity table with autoincrement integer primary key
*
* @param name table name, by default name will be resolved from a class name with "Table" suffix removed (if present)
* @param columnName name for a primary key, "id" by default
*/
open class IntIdTable(name: String = "", columnName: String = "id") : IdTable<Int>(name) {
final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement().entityId()
final override val primaryKey by lazy { super.primaryKey ?: PrimaryKey(id) }
}This field was earlier not final and we were able to override it for several tables by combining/linking two tables:
object AnswersInQuestionTable : IntIdTable("answers_in_question"){
val question = reference("question_id", QuestionsTable)
val answer = reference("answer_id", AnswersTable)
override val primaryKey = PrimaryKey(question, answer)
}This is a an issue for our web service. Anyone who know what the best practice(s) are for resolving that?
Filip Lastic
01/03/2022, 10:35 AMdataSource
isolation?
I am using HikariCP as datasource and I defined hikariDataSource.transactionIsolation = "TRANSACTION_READ_COMMITED"
. But when I call
transaction {
val level = this.transactionIsolation
}
value of the level
variable is different than isolation specified for dataSource..d.medina
01/05/2022, 7:30 PMdany giguere
01/05/2022, 11:05 PMval config = HikariConfig().apply {
jdbcUrl = "jdbc:<mysql://localhost/dbname>"
driverClassName = "com.mysql.cj.jdbc.Driver"
username = "username"
password = "secret"
maximumPoolSize = 10
}
val dataSource = HikariDataSource(config)
Database.connect(dataSource)
from the documentation here: https://github.com/JetBrains/Exposed/wiki/DataBase-and-DataSourcebrabo-hi
01/07/2022, 6:02 AMr2dbc
with exposedSourabh Rawat
01/16/2022, 3:04 PM@Test
fun dbTest2() {
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver")
transaction {
SchemaUtils.create(Blogs)
}
transaction {
Blog.all().also { println(it.toList()) }
Blog.new {
title = "asd"
rawContent = "foo"
}
Blog.all().also { println(it.toList()) }
}
}
with Table "BLOGS" not found (this database is empty)
even though I can see that create table call executed before
2022-01-16 20:32:57.273 [Test worker] DEBUG Exposed - CREATE TABLE IF NOT EXISTS BLOGS (ID INT AUTO_INCREMENT PRIMARY KEY, TITLE VARCHAR(100) NOT NULL, RAW_CONTENT TEXT NOT NULL, CREATE_DATE_TIME DATETIME(9) NOT NULL, UPDATE_DATE_TIME DATETIME(9) NOT NULL)
2022-01-16 20:32:57.289 [Test worker] DEBUG Exposed - SELECT BLOGS.ID, BLOGS.TITLE, BLOGS.RAW_CONTENT, BLOGS.CREATE_DATE_TIME, BLOGS.UPDATE_DATE_TIME FROM BLOGS
martmists
01/19/2022, 12:23 PMobject CommentTable : LongIdTable() {
val post = reference("post", PostTable)
val parent = optReference("parent", CommentTable)
val author = reference("author", UserTable)
val content = text("content")
val created = datetime("created")
val updated = datetime("updated")
}
but when doing CommentTable.parent eq null
I get
Overload resolution ambiguity:
public open fun <T : Comparable<TypeVariable(T)>, E : EntityID<TypeVariable(T)>?> ExpressionWithColumnType<TypeVariable(E)>.eq(t: TypeVariable(T)?): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
public open fun <T> ExpressionWithColumnType<TypeVariable(T)>.eq(t: TypeVariable(T)): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
Jonathan Derin
01/19/2022, 3:04 PMJonathan Derin
01/19/2022, 3:04 PM