• p

    Pepperbc

    2 years ago
    Hi - is there a way to create the SQL for { it[name] = "foo" } and { it[director] = "bar") }, to then later combine them and call Movies.update() { it[name] = "foo") ; it[director] = "bar" }
    p
    e
    2 replies
    Copy to Clipboard
  • Joel

    Joel

    2 years ago
    It's unclear to me how the default connection works. The docs say the latest connection is the default. Does this truly mean that the latest call of
    Database.connect
    is the default db? This is inconvenient when working with Spring Boot because bean creation order is undefined.
    Joel
    hichem fazai
    +1
    15 replies
    Copy to Clipboard
  • Joel

    Joel

    2 years ago
    @tapac thanks for the postgres index fix! Am I looking for a 0.26.2?
    Joel
    1 replies
    Copy to Clipboard
  • tapac

    tapac

    2 years ago
    Hello, everyone! Long time no see. Sorry for "silence mode" while I was on vacation with almost no internet. But I'm back and plan to check all new issues and PR in a few days. There are a few bug fixes pending in a master branch, so let's start with a bug-fix release 0.26.2. Please, check release note to see the full list of changes.
    tapac
    1 replies
    Copy to Clipboard
  • Yoavya

    Yoavya

    2 years ago
    Hi, I want to create a custom count, normally when I want to count a column I just
    columnX.count()
    in the slice part of the query. I want to do something like this
    count(*) filter ( where columnX in ('a', 'b') ) as custom_count
    is there an easy way to achieve this? Thanks 🙂
    Yoavya
    Joel
    +1
    9 replies
    Copy to Clipboard
  • Joel

    Joel

    2 years ago
    @tapac welcome back! Hopefully an easy question as you dive back into code - does the new composite column support nullability?
    Joel
    tapac
    2 replies
    Copy to Clipboard
  • t

    Tobias G. Waaler

    2 years ago
    Hi, Thank you for creating Exposed, I'm having a great time learning the library 🙂 I was just wondering if it would be a good idea to change the
    adjustSlice
    function from
    fun adjustSlice(body: ColumnSet.() -> FieldSet): Query = apply { set = set.source.body() }
    to something like
    fun adjustSlice(body: ColumnSet.(FieldSet) -> FieldSet): Query = apply { set = set.source.body(set) }
    That way you can get a hold of fields that are currently a part of the fieldset for the query and do things like adding additional fields (or even removing fields). To me this was useful when I wanted to add a single extra field to the slice, depending on some condition. Currently I've created this extension function that I'm using, and it works quite well:
    fun Query.addToSlice(vararg columns: Expression<*>): Query {
        return adjustSlice {
            slice(this@addToSlice.set.fields + columns)
        }
    }
    t
    tapac
    2 replies
    Copy to Clipboard
  • Joel

    Joel

    2 years ago
    The JDBC layer is parsing the value to
    BigDecimal
    correctly but it appears that Exposed is rounding the precision to that of the original column.
    Joel
    tapac
    3 replies
    Copy to Clipboard
  • mmaillot

    mmaillot

    2 years ago
    Hi! I have a
    UUIDTable
    Interventionwith a child:
    val foreignEnterprise = reference("foreign_enterprise", ForeignEnterprises.id)
    . I want to get the foreign enteprise for an intervention. I have the
    InterventionUuid
    . How can I do ? In SQL, I do: SELECT foreign_enterprise.* from foreign_enterprise, intervention WHERE intervention.foreign_enteprise_id = foreign_enterprise_id AND intervention.id ='INPUT_UUID'.
    mmaillot
    Joel
    3 replies
    Copy to Clipboard
  • Philipp Mayer

    Philipp Mayer

    2 years ago
    Hey guys! I'm currently working with Exposed and its a breeze! However, I stumbled upon a thing that I don't quite understand yet. I have the following table:
    object Sensors : IntIdTable() {
        val roomId = reference("id", Rooms.id).nullable()
        val name = text("name")
    }
    And now I just want to select all rows and map them to my domain Object:
    class Sensor(
            val id: Int?,
            val roomId: Int?,
            val name: String
    )
    
    Sensors.selectAll().map {
          Sensor(it[id], it[roomId], it[name])
    }
    However, if I do it as shown, I get an alert saying that
    it[id]
    is of type string (while I expect an int). Ist htere a better way? Why is it like that, even though my table definition is different? Thanks in advance!
    Philipp Mayer
    tapac
    2 replies
    Copy to Clipboard