MichaelMalus
01/14/2019, 4:28 AMtable.selectAll()
just fine. Trying to SELECT WHERE (as in table.select(table.columname eq foobar)
), I get Unresolved reference: eq
. What am I missing?runjorel
01/18/2019, 4:29 PMResultRow
? Long story short I wanted to create a delegate class to ResultRow but I don’t believe its possible due to ResultRow not being open.Kevin
01/20/2019, 2:42 PMtransaction(Connection.TRANSACTION_SERIALIZABLE, 1) {
Message
.slice(Message.text)
.selectAll()
.limit(10)
.forEach { println(it) }
}
But when I try to return the rows and use them outside of the transaction, it doesn’t seem to work:
val messages = transaction(Connection.TRANSACTION_SERIALIZABLE, 1) {
Message
.slice(Message.text)
.selectAll()
.limit(10)
.toList()
}
messages.forEach { println(it) }
I’m getting java.lang.IllegalStateException: No transaction in context
.
When I set a breakpoint after the transaction, messages
has length 10, but trying to access any elements throws an exception.
I’m pretty new to this and wasn’t able to find anything by googling. Could someone help me figure out what I have wrong?Marcin Wisniowski
01/23/2019, 5:35 PMwrapRows
back?Tasos Stamadianos
01/24/2019, 12:18 AMPostGIS
support, and I'd like to call a PostGIS
function during an insert, but I really can't figure out how to do this. I've seen examples involving ExpressionWithColumnType
, but nothing that actually uses this function during an insert
in a transaction
. Some relevant code:
abstract class SQLFunction<T>(override val columnType: IColumnType) : ExpressionWithColumnType<T>()
class ST_Centroid(private val poly: MultiPolygon): SQLFunction<Point>(PointColumnType()) {
override fun toSQL(queryBuilder: QueryBuilder) = "ST_Centroid($poly)"
}
I'm trying to do this now:
[DbFields.center] = ST_Centroid(boundaryPoly)
where boundaryPoly
is a PostGIS multipolygon.
Any help would be greatly appreciated 🙂APXEOLOG
01/26/2019, 12:57 AMhyukchan
01/27/2019, 1:30 PMEdouard Goossens
01/28/2019, 9:55 PMSELECT field1, field2, field2-field1 AS diff FROM table
using DAO. Thanks!Kevin
01/29/2019, 8:10 AMselect date, message.ROWID, id, text, filename, is_from_me, mime_type
from message
left join handle on message.handle_id = handle.ROWID
inner join chat_message_join c on message.ROWID = c.message_id and c.chat_id = 259
left join message_attachment_join maj on message.ROWID = maj.message_id
left join attachment a on maj.attachment_id = a.ROWID;
I’m pretty new to exposed and SQL in general, so I’m not sure if this is even the right way to do things in SQL.Alexander Potukar
01/30/2019, 10:39 AMbjonnh
02/02/2019, 12:26 AMsamir
02/06/2019, 10:28 AMSET @total = 2;
PREPARE STMT FROM "SELECT * FROM my_table LIMIT ?";
EXECUTE STMT USING @total;
I know that this is not type safe and that it is better to use DSL/DAO but the requirements is that statements should be defined as strings from an admin interface.
Exception in thread "main" org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PREPARE STMT FROM "SELECT * FROM my_table LIMIT ?";
EXECUTE STMT USING @total' at line 2
SQL: [SET @total = 2;
PREPARE STMT FROM "SELECT * FROM my_table LIMIT ?";
EXECUTE STMT USING @total;]
Kevin
02/08/2019, 8:49 AMtimm
02/10/2019, 8:41 PMoverride val id: Column<EntityID<Long>> = long("id").autoIncrement("hibernate_sequence").primaryKey().entityId()
Hasan
02/11/2019, 2:12 PMExposed
and trying to use it with postgresql
. I imported the latest verison of the postgresql jdbc driver
using the maven dependency:
maven
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5.jre7</version>
<type>bundle</type>
</dependency>
And I attempted to connect to the database using:
kotlin
Database.connect(
"jdbc:<postgresql://localhost:5432/my_db>",
driver = "org.postgresql.Driver",
user = "postgres",
password = "welcome")
And this is the error I'm getting:
Exception in thread "main" java.lang.ClassNotFoundException: org.postgresql.Driver at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) at
java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) at
java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:291) at
org.jetbrains.exposed.sql.Database$Companion.connect(Database.kt:112) at
org.jetbrains.exposed.sql.Database$Companion.connect$default(Database.kt:111) at
com.example.test.ExposedTest.connect(ExposedTest.kt:30) at com.example.test.HelloKt.main(Hello.kt:5)
Can you spot what I might be doing wrong? Thanks in advance!pjagielski
02/13/2019, 11:35 AMKevin
02/18/2019, 11:12 AMStatementInterceptor
and overrode the beforeExecution
and afterExecution
methods. Is this the right approach? Or am I missing some functionality that is already built in?tjb
02/19/2019, 4:19 AMtjb
02/19/2019, 6:38 AMreturn transaction {
PostDAO.wrapRows(
Posts
.innerJoin(PostsTags, {Posts.id}, {<http://PostsTags.post|PostsTags.post>})
.innerJoin(Tags, {Tags.id}, {PostsTags.tag})
.selectAll()
.andWhere {
Posts.title like "%$query%" or (Tags.name inList tags)
}
.withDistinct()
).map {
it.toModel()
}
.distinct()
.toList()
}
lovis
02/20/2019, 2:24 PMselect
clause.
Someone who’s used to sql would expect the dsl to work something like this:
val gamailUsers = Users.select(id, name, email)
.where { email like "%@gmail.com"}
.map { ... }
But instead expose uses slice
to do the projection. And select to do the selection. Why is this? I don’t realy have an opinion, I just want to know what the reason behind this decision was.Vinicius Carvalho
03/01/2019, 9:05 PM15:58:19.284 [main] DEBUG Exposed - SELECT products.upc, products.sku, products.name, products.price, products.type, products.manufacturer, products.description, products.model, products.image, products.last_updated FROM products WHERE products.upc = 12
SQL: SELECT products.upc, products.sku, products.name, products.price, products.type, products.manufacturer, products.description, products.model, products.image, products.last_updated FROM products WHERE products.upc = 12
15:58:40.625 [main] WARN Exposed - Transaction attempt #1 failed: Invalid argument value: java.io.NotSerializableException. Statement(s): null
java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
asad.awadia
03/03/2019, 9:16 PMarea_code_column + phone_number_column inList listOf(...)
bdawg.io
03/04/2019, 6:44 PMgalex
03/05/2019, 5:55 AMgalex
03/06/2019, 7:46 AMSrSouza
03/06/2019, 4:52 PMdaoObj.name = "new Name"
transaction(database) {
daoObj.update()
}
Something like this have?galex
03/08/2019, 8:01 AMcedric
03/10/2019, 10:42 PMspand
03/14/2019, 9:35 AMnull
of a .nullable()
column ? Many of these decorating functions are defined as fun <T:Any> Column<T>.default(
spand
03/14/2019, 9:51 AMInsertStatement.get
return T?
? The only use in the project that ought to use this functionality at all is fun <Key:Comparable<Key>, T: IdTable<Key>> T.insertIgnoreAndGetId
.
It seems to me that it ought to be changed to T
and instead define a InsertStatement.tryGet
for the much rarer use so can avoid having !! just to retrieve a generated key.