• s

    Slackbot

    2 years ago
    This message was deleted.
    s
    s
    2 replies
    Copy to Clipboard
  • e

    Evan R.

    2 years ago
    Hey @tapac just wanted to give you a shoutout for all the hard work you do on this library, it’s genuinely a really nice way to interact with SQL servers and I like it a lot. Kudos for maintaining the library and also responding quickly to all our questions on this channel!
    e
    tapac
    2 replies
    Copy to Clipboard
  • Kabbura

    Kabbura

    2 years ago
    Hey @tapac, I was debugging an issue with my code and finally found that the problem is that the
    limit
    function does not generate sql when the limit size is 0, as the function implementation is
    open fun queryLimit(size: Int, offset: Int, alreadyOrdered: Boolean) = buildString {
        if (size > 0) {
            append("LIMIT $size")
            if (offset > 0) {
                append(" OFFSET $offset")
            }
        }
    }
    Shouldn't be
    if (size >= 0)
    instead? My use case is that the limit size is generated dynamically, and when it is 0, the sql query results should be empty.
    Kabbura
    tapac
    2 replies
    Copy to Clipboard
  • r

    Reuben Jacobs

    2 years ago
    Is there an efficient way to update a model field in exposed only in the case that the value for the column in the DB is different than what I have in a variable?
    r
    1 replies
    Copy to Clipboard
  • codec

    codec

    2 years ago
    In jetbrains.exposed.sql.Transaction.kt version 0.3, there was a
    create(vararg tables: Table){}
    method. I just updated to exposed version 0.22. What happened to this method!? 😞
    codec
    tapac
    5 replies
    Copy to Clipboard
  • Rasheed Sulayman

    Rasheed Sulayman

    2 years ago
    Hello, Is there a way to get use store and retrieve
    data
    classes directly with exposed, something like:
    object Users : Table() {}
    
    // Get list of users
    val usersList: List<User> = Users.select { Users.city.eq("a city") }
    
    //Insert users 
    
    val allUsers: List<User> = //list of users 
    val aUser: User = //User instance
    
    Users.insertAll(allUsers) // Inserts everything in to the user table
    Users.insert(aUser) // Inserts a single user in to the table.
    i.e Something that automatically maps/converts rows to data classes when reading stuff, and vice versa when inserting.
    Rasheed Sulayman
    codec
    +2
    6 replies
    Copy to Clipboard
  • Nikky

    Nikky

    2 years ago
    i am trying to put datetimes in with exposed.. .. my local timezone is
    Europe/Berlin
    so i tried converting them like so
    ISODateTimeFormat.dateTimeParser().parseDateTime(dateString).withZone(DateTimeZone.UTC)
    and logging shows me the field should be
    2020-03-18T16:17:00.000Z
    but when i look into the database i see
    2020-03-18 17:17:00
    this looks almost as if exposed converts to the local timezone and then discards the timezone info (or
    DATETIME
    has no timezone info?) how can i make sure i save stuff as
    UTC
    always ?
    Nikky
    1 replies
    Copy to Clipboard
  • s

    Slackbot

    2 years ago
    This message was deleted.
    s
    tapac
    +2
    5 replies
    Copy to Clipboard
  • d

    DownloadPizza

    2 years ago
    I need some help with a project. I have a table like this
    object Parks : Table("p_parks") {
        val id = varchar("p_id", 45)
        val longitude = double("longitude")
        val latitude = double("latitude")
    
        override val primaryKey = PrimaryKey(id)
    }
    and im trying to select them by distance to a coordinate
    c
    with latitude
    lat
    and longitude
    lon
    , but i dont want to filter them by smth like "less than 10km away" but i want the 10 nearest. Is there any way to do this without selecting all?
    d
    Emil Kantis
    6 replies
    Copy to Clipboard
  • d

    DownloadPizza

    2 years ago
    and my function to get the distance is
    fun distanceBetween(cord1: Coordinates, cord2: Coordinates): Double {
        val (lat1deg, lon1deg) = cord1
        val (lat2deg, lon2deg) = cord2
    
        val r = 6371e3; // metres
        val lat1 = lat1deg.toRadians()
        val lat2 = lat2deg.toRadians()
        val deltaLat = (lat2deg - lat1deg).toRadians()
        val deltaLon = (lon2deg - lon1deg).toRadians()
    
        val a = sin(deltaLat / 2).pow(2) +
                cos(lat1) * cos(lat2) * sin(deltaLon / 2).pow(2)
        val c = 2 * atan2(sqrt(a), sqrt(1 - a))
    
        return r * c;
    }
    d
    1 replies
    Copy to Clipboard