[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libeufin] branch master updated: nested DB queries
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libeufin] branch master updated: nested DB queries |
Date: |
Fri, 18 Oct 2019 16:55:05 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new d213843 nested DB queries
d213843 is described below
commit d213843ce31f97d68c76ffc3602b4c649a832a5e
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Oct 18 16:54:57 2019 +0200
nested DB queries
---
sandbox/src/main/kotlin/DB.kt | 14 ++++++++------
sandbox/src/test/kotlin/DbTest.kt | 22 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/sandbox/src/main/kotlin/DB.kt b/sandbox/src/main/kotlin/DB.kt
index 7405cb4..0a91581 100644
--- a/sandbox/src/main/kotlin/DB.kt
+++ b/sandbox/src/main/kotlin/DB.kt
@@ -71,7 +71,7 @@ enum class KeyStates {
*/
object BankCustomers: IntIdTable() {
// Customer ID is the default 'id' field provided by the constructor.
- val name = varchar("name", CUSTOMER_NAME_MAX_LENGTH)
+ val name = varchar("name", CUSTOMER_NAME_MAX_LENGTH).primaryKey()
val ebicsSubscriber = reference("ebicsSubscriber", EbicsSubscribers)
}
@@ -93,7 +93,7 @@ class BankCustomer(id: EntityID<Int>) : IntEntity(id) {
object EbicsUsers: IntIdTable() {
/* EBICS user ID in the string form. */
- val userId = varchar("userId", EBICS_USER_ID_MAX_LENGTH).nullable()
+ val userId = varchar("userId",
EBICS_USER_ID_MAX_LENGTH).primaryKey().nullable()
}
@@ -112,7 +112,7 @@ class EbicsUser(id: EntityID<Int>) : IntEntity(id){
* Table for UserID.
*/
object EbicsPartners: IntIdTable() {
- val partnerId = varchar("partnerId",
EBICS_PARTNER_ID_MAX_LENGTH).nullable()
+ val partnerId = varchar("partnerId",
EBICS_PARTNER_ID_MAX_LENGTH).primaryKey().nullable()
}
@@ -174,9 +174,11 @@ class EbicsPublicKey(id: EntityID<Int>) : IntEntity(id) {
* and systems. Each value can appear multiple times in the same column.
*/
object EbicsSubscribers: IntIdTable() {
- val userId = reference("UserId", EbicsUsers)
- val partnerId = reference("PartnerId", EbicsPartners)
- val systemId = reference("SystemId", EbicsSystems)
+
+
+ val userId = reference("userId", EbicsUsers)
+ val partnerId = reference("partnerId", EbicsPartners)
+ val systemId = reference("systemId", EbicsSystems)
val signatureKey = reference("signatureKey", EbicsPublicKeys).nullable()
val encryptionKey = reference("encryptionKey", EbicsPublicKeys).nullable()
diff --git a/sandbox/src/test/kotlin/DbTest.kt
b/sandbox/src/test/kotlin/DbTest.kt
index 69fbcde..a827c3d 100644
--- a/sandbox/src/test/kotlin/DbTest.kt
+++ b/sandbox/src/test/kotlin/DbTest.kt
@@ -1,9 +1,12 @@
package tech.libeufin.sandbox
+import junit.framework.TestCase.assertFalse
import org.jetbrains.exposed.dao.EntityID
+import org.jetbrains.exposed.dao.IntEntityClass
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.transactions.transaction
import org.junit.BeforeClass
+import junit.framework.TestCase.assertTrue
import org.junit.Test
import org.junit.Before
@@ -33,6 +36,8 @@ class DbTest {
}
}
+
+
@Test
fun nestedQuery() {
@@ -43,5 +48,22 @@ class DbTest {
* EbicsSubscribers.userId.userId eq "u1"
* }.first()
*/
+
+ transaction {
+ createSubscriber()
+
+ val tmp = EbicsUser.find { EbicsUsers.userId eq "u1"
}.firstOrNull()
+ if (tmp == null) {
+ logger.error("No such user found in database.")
+ return@transaction
+ }
+ println("Found user with id: ${tmp.id.value}")
+
+ val found = EbicsSubscriber.find {
+ EbicsSubscribers.userId eq EntityID(tmp.id.value, EbicsUsers)
+ }
+
+ assertFalse(found.empty())
+ }
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [libeufin] branch master updated: nested DB queries,
gnunet <=