• tapac

    tapac

    1 year ago
    Expose 0.31.1 released with TIME column support (java-time only), inList on Pairs and Triples, few fixes, and performance improvement. Check change log for details.
    tapac
    b
    +1
    4 replies
    Copy to Clipboard
  • Ali Olfat

    Ali Olfat

    1 year ago
    hey folks, is there a way to know if my row was inserted or not with
    insertIgnore
    on a non IdTable? I'm currently querying for it right afterwards but was wondering if there is a cleaner way
    Ali Olfat
    1 replies
    Copy to Clipboard
  • Luca Sas

    Luca Sas

    1 year ago
    Hi, I am on ktor 1.5.2 and I am having issues with SchemaUtils.create. I have 3 tables, and the third has a reference to the first one. When it gets to creating the third table it concludes that the first one doesnt exist and tries to create it again which causes an error "relation "users_username_unique" already exists". I debugged and stepped thru the code and found that the problem is in VendorDialect.tableExists function.
    override fun tableExists(table: Table): Boolean {
            val tableScheme = table.tableName.substringBefore('.', "").takeIf { it.isNotEmpty() }
            val scheme = tableScheme?.inProperCase() ?: TransactionManager.current().connection.metadata { currentScheme }
            val allTables = getAllTableNamesCache().getValue(scheme)
            return allTables.any {
                when {
                    tableScheme != null -> it == table.nameInDatabaseCase()
                    scheme.isEmpty() -> it == table.nameInDatabaseCase()
                    else -> it == "$scheme.${table.tableNameWithoutScheme}".inProperCase()
                }
            }
        }
    What happens here by looking at the debugger is that
    alltables
    is
    [ "public.tablename", "public.someothertablename" ]
    but
    table.name
    misses the schema name and I am not sure why. The code is fairly straightforward and I used
    SchemaUtils.create
    successfully in the past.
    Luca Sas
    1 replies
    Copy to Clipboard
  • Dominick

    Dominick

    1 year ago
    Do I need to call Database.connect(dataSource) every time I create a transaction? I'm receiving errors and I'm kind of confused because I do call it after I create the datasource
    Dominick
    dave08
    2 replies
    Copy to Clipboard
  • Dominick

    Dominick

    1 year ago
    It's possible that my database doesn't connect. I just went into my database and it doesn't seem that it created anything:
    val dataSource = HikariDataSource().apply {
            maximumPoolSize = 20
            driverClassName = "com.mysql.jdbc.Driver"
            jdbcUrl = File("jdbc_url.txt").readText()
            isAutoCommit = false
        }
    
        Database.Companion.connect(dataSource)
    
        transaction {
            SchemaUtils.create(MediaPropertiesTable)
            SchemaUtils.create(MediaContentTable)
            SchemaUtils.create(UserAPIKeysTable)
            SchemaUtils.create(UserTable)
        }
    The file jdbc_url.txt does exist and has a connection url generated from pterodactyl UPDATE: Tried removing pterodactyl from the equation and still doesnt work. It gets past the create code and all, nothing gets logged even after adding
    addLogger(StdOutSqlLogger)
    and the tables arent in the db.
    Dominick
    b
    +1
    5 replies
    Copy to Clipboard
  • j

    Joost Klitsie

    1 year ago
    Hi all! I wish to create some custom column types, mainly to wrap inline classes for UUID's. I have multiple classes that wrap a UUID, and I was wondering that if there is any guide to help me through it? I could copy paste and adjust the UUIDColumnType, but I was wondering, is it somehow possible to wrap something around it?
    j
    e
    9 replies
    Copy to Clipboard
  • christophsturm

    christophsturm

    1 year ago
    does expose always use threadLocals? i thought that if I pass around a database and always specify the database like
    transaction(db) {..}
    it will avoid threadlocals, but it seems that all exposed calls inside the transaction still get their transaction from a threadlocal. so it only works if the thread stays the same, and for example it wont work if i have callbacks (or coroutines) that potentielly run in different threads.
    christophsturm
    Emil Kantis
    +1
    3 replies
    Copy to Clipboard
  • Emil Kantis

    Emil Kantis

    1 year ago
    I'm getting some odd error regarding with DAOs when writing tests
    <http://dao.Companies.org|dao.Companies.org>_id is not in record set
    . All tables are created in the same transaction as the test then everything is rolled back. I've tried using both H2 and SQLite, getting same error with both.. Not sure where to start looking. Most search hits seems to be related to renaming the id column, but this is a FK to another entity
    Emil Kantis
    Marcus Ilgner
    3 replies
    Copy to Clipboard
  • Ali Albaali

    Ali Albaali

    1 year ago
    Is there a way to return a
    Flow
    from a query?
    Ali Albaali
    j
    9 replies
    Copy to Clipboard
  • s

    spand

    1 year ago
    Am I missing a way to put a Query in the slice ? ie.
    INSERT INTO Tbl (parentId, number)
    VALUES (42,
            COALESCE((SELECT MAX(aTbl.number) FROM Tbl as aTbl WHERE aTbl.parentId = 42) + 1, 1)
            );
    I kind of expected a way to turn a query into an Expression<Int>.
    s
    1 replies
    Copy to Clipboard