Daniel Skogquist Åborg
01/21/2021, 3:09 PMtapac
01/25/2021, 1:08 PMEndre Deak
01/26/2021, 1:32 AMUNION
. I need UNION
in my query, so I was wondering if I could wrap an SQL statement (something like SELECT 1 AS idx UNION ALL SELECT 2 UNION ALL SELECT 3
) and then I could use this expression to join to another table?Kuba Petržílka
01/28/2021, 7:58 PMDas135
02/05/2021, 8:42 AMautoincrement
insert for MSSQL?
I have column in Table defined like this:
val id: Column<Long> = long("id").autoIncrement("users_seq")
override val primaryKey: PrimaryKey = PrimaryKey(id)
And when inserting object (without defined inc column) I get this error:
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'id', table ''; column does not allow nulls. INSERT fails.
2. How to store NULL value to varbinary(max)
MSSQL column with Exposed? I have this column type:
val image = binary("image", Int.MAX_VALUE).nullable()
When trying to insert null value, I get error:
Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
Tarun Chawla
02/13/2021, 12:25 PMFeb 13, 2021 5:28:37 PM com.impossibl.postgres.jdbc.ThreadedHousekeeper$HousekeeperReference cleanup
WARNING: Cleaning up leaked result-set
Allocation occurred @
at org.jetbrains.exposed.sql.statements.jdbc.JdbcPreparedStatementImpl.executeQuery(JdbcPreparedStatementImpl.kt:21)
at org.jetbrains.exposed.sql.Query.executeInternal(Query.kt:79)
at org.jetbrains.exposed.sql.Query.executeInternal(Query.kt:15)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:61)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:129)
Due to this elephant sql is complaining about too many multiple connections. Am using exposed version 0.29.1 and latest pgjdbc-ng:0.8.6. Please help me understand the issue and share any code snippet if any.
Am opening db connection like below:
fun getDBConn(): Database? {
if (DBConnection == null) {
synchronized(this) {
if (DBConnection == null) {
try {
DBConnection = DataBaseConnection.connectWithDb(
Config.DB_URL,
Config.DB_DRIVER,
Config.DB_USERNAME,
Config.DB_PASSWORD
)
} catch (e: Exception) {
println("error while connecting to db $e")
return null
}
}
}
}
return DBConnection
}
Kuba Petržílka
02/15/2021, 8:37 AMtimestamptz
in postgres I used timstamp(...)
(Column<Instant>
from Java Time API extension for Exposed) and when I persist a record it uses my current timezone, but I would like to get it persisted in GMT so that I dont have to do that math when comparing the values while looking into the DB (I want 2021-02-14 15:06:07.66052+00
instead of 2021-02-14 16:06:07.66052+01
) how do I enforce this?Kuba Petržílka
02/16/2021, 2:07 PMEndre Deak
02/17/2021, 5:06 PMMark
02/17/2021, 7:53 PMEntity#new
that does INSERT IGNORE INTO
instead of just INSERT INTO
?shengyou
02/19/2021, 8:15 AMDatabase.connect(
url = "jdbc:sqlite::memory:",
driver = "org.sqlite.JDBC"
)
TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
Follow the wiki and use Database.connect(“jdbc:sqlite:file:test?mode=memory&cache=shared”, “org.sqlite.JDBC”)
and doesn’t work either. Not sure what I missing? Any suggestions are appreciated. Thanks!Adam
02/19/2021, 1:04 PMLocalDate
(via the JavaLocalDateColumnType
class).
LocalDate
does not contain a timezone, but JavaLocalDateColumnType
converts the LocalDate
to a java.sql.Date
object using the local timezone.
This means that, if my timezone is UTC+n, saving a LocalDate
of, for example 1991-01-01
will put 1990-12-31
in the DB.
Have I misunderstood or overlooked something? This behaviour doesn’t seem to be correct. SQL `DATE`s are timezone free, so are LocalDate
s so there shouldn’t be any timezone conversion happening.Daniel Skogquist Åborg
02/19/2021, 1:35 PMAdam Crane
02/23/2021, 7:40 PMLuca Sas
03/01/2021, 3:49 PMpjagielski
03/03/2021, 8:57 AMEndre Deak
03/03/2021, 10:29 PMJoin
? I saw Join.joinParts
but that’s not accessible from outside - looks like it’s not 100% prepared for a use-case where the same table can be joined with a different alias.Robert
03/05/2021, 4:59 PMsolidogen
03/05/2021, 9:29 PMsolidogen
03/06/2021, 2:17 PMRay
03/07/2021, 7:44 PMjava.util.NoSuchElementException: List is empty.
and i'm pretty certain the list is not empty. Also please note l'm relatively new to working with ktor/exposed. I'll really appreciate any help cos it's really difficult to find helpful post or video tutorials on ktor/exposed.
var statement: InsertStatement<Number>? = null
var addOnStatement: List<ResultRow>?
var foodSizeStatement: List<ResultRow>?
var foodAddOns = emptyList<com.df.backend.model.FoodAddOn>()
var foodSizes = emptyList<com.df.backend.model.FoodSize>()
dbQuery {
statement = Foods.insert { food ->
food[name] = foodRequest.name
food[description] = foodRequest.description
food[category] = foodRequest.category
food[foodImage] = foodRequest.foodImage
food[createdAt] = foodRequest.createdAt
food[updatedAt] = foodRequest.updatedAt
}
val resultRow = statement?.resultedValues?.get(0)
println("Food count ${statement?.resultedValues?.size}")
println("Addon List ${foodRequest.foodAddOns.size}")
addOnStatement = FoodAddOn.batchInsert(foodRequest.foodAddOns) { addOn ->
this[FoodAddOn.name] = addOn.name
this[FoodAddOn.addOnPrice] = addOn.addOnPrice
this[FoodAddOn.foodAddOnImage] = addOn.foodAddOnImage
this[FoodAddOn.foodId] = resultRow?.get(Foods.foodId)!!
}
foodAddOns = rowToAddOns(addOnStatement!!)
foodSizeStatement = FoodSize.batchInsert(foodRequest.foodSizes) { foodSize ->
this[FoodSize.size] = foodSize.size
this[FoodSize.sizePrice] = foodSize.sizePrice.toInt()
this[FoodSize.foodId] = resultRow?.get(Foods.foodId)!!
}
foodSizes = rowToSizes(foodSizeStatement!!)
}
return rowToFood(statement?.resultedValues?.get(0),foodAddOns, foodSizes )
Rodrigo Felizola Medeiros
03/24/2021, 9:28 PMJohn Pena
03/26/2021, 2:44 PMIllegalStateException: No transaction in context
. anyone know what i’m doing wrong here?
val breakdownDimensions = transaction {
Dimension.find {
Dimensions.id inList breakdownIds
}
}
for (dimension in breakdownDimensions) {
println(dimension.id)
}
phobe
03/28/2021, 1:20 AMMarcel Overdijk
03/31/2021, 12:24 PMSchemaUtils
has a createStatements
fun that could do the DDL part, but I cannot find anything to simply generate the SQL for inserts.Wishnuprathikantam
04/01/2021, 11:30 AMAPXEOLOG
04/02/2021, 10:55 AMtapac
04/02/2021, 11:29 AMWildOne (Yuri)
04/02/2021, 12:19 PMval agents: ObservableList<AgentModel> by lazy {
transaction(db) {
addLogger(StdOutSqlLogger)
AgentEntity.all().map {
AgentModel().apply {
item = it
}
}.toObservable()
}
}
yet it seems like I can't get the UI to update when the DB changes. Do I need to update the agents list manually?WildOne (Yuri)
04/03/2021, 6:13 AM