Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Flavio W. Brasil
    @fwbrasil
    maybe you can provide the implicit by using MappedColumnType.base
    this is the way that the TypedType is provided for entities ^
    Ryan Proud
    @spry-rproud
    Ok, I'll look into it. Thanks.
    Flavio W. Brasil
    @fwbrasil
    y’re welcome, maybe try to find slick examples using enums
    Ryan Proud
    @spry-rproud
    Ok
    Ryan Proud
    @spry-rproud
    I think I found a solution to the slick enum issue. I'm running into problems with the Val enums used for Activate though. My enumerations are failing comparisons. The indexes on values that should be equivalent (they have the same name) are different. Also when I inspect the vmap of the outerEnum there are duplicates.
    Ryan Proud
    @spry-rproud
    Ok, I finally realized what was going on with the enums. I think this may be a serious flaw with the use of Enumerations in activate.
    object Status extends Enumeration {
      case class Status(name: String) extends Val(name)
      val ACTIVE = Status("active")
      val INACTIVE = Status("inactive")
    }
    
    val a = Status.ACTIVE
    val b = Status.Status("active")
    
    val c = a == b // false
    val d = a.name == b.name // true
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud being a case class Status should return true if two instances have the same name
    c is true for running this code
    Ryan Proud
    @spry-rproud
    It's not because Status also has an index which is not equivalent
    Flavio W. Brasil
    @fwbrasil
    but if the vmap has multiple instances with the same name there is indeed something wrong
    let me test the code again
    Ryan Proud
    @spry-rproud
    Also is it expected behaviour for postgresql not to create implicit indexes when creating tables via Migrations?
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud could you describe again the issue with enumerations? i did some tests, but couldn’t reproduce
    @spry-rproud index for the fks?
    Ryan Proud
    @spry-rproud
    both PK and FK
    I have run my migration and have 0 indexes in the db.
    I'm just wondering if I need to explicitly create them in the migration.
    Flavio W. Brasil
    @fwbrasil
    i think it the db already creates indexes for primary keys
    for fks, it is necessary to create “manually"
    Ryan Proud
    @spry-rproud
    Ok
    Flavio W. Brasil
    @fwbrasil
    about the enums, could you open an issue with more info?
    i couldn’t reproduce
    Ryan Proud
    @spry-rproud
    If you run the above code it doesn't fail on the comparison of a and b?
    Flavio W. Brasil
    @fwbrasil
    yes, it fails
    Ryan Proud
    @spry-rproud
    So the problem is that any serializer (json4s, etc.). Just serializes the case class and creates a new instance of Status.Status. This will cause a failure comparing with anything created using Status.withName(name).
    There's also no protection from anyone doing the same thing in code.
    Flavio W. Brasil
    @fwbrasil
    i see, so the problem happens only when the entity is serialized?
    Ryan Proud
    @spry-rproud
    or if someone creates Status.Status("active")
    Which given the definition of the Enumeration they are free to do.
    Flavio W. Brasil
    @fwbrasil
    do you know how json4s deserializes enums?
    or in this case it deserializes as a common class?
    Flavio W. Brasil
    @fwbrasil
    if it is this code that is being used, it is the same way that activate does
    using enum.withName
    Ryan Proud
    @spry-rproud
    Sorry that's how they serialize a typical Enumeration, the problem is the value isn't an Enumeration it's a case class.
    I'm just saying it would be safer if Activate allowed Enumerations defined as follows. This would prevent these types of issues.
    object Status extends Enumeration {
        val ACTIVE = Value("active")
        val INACTIVE = Value("inactive")
    }
    Flavio W. Brasil
    @fwbrasil
    it would be better, but it isn’t possible
    Ryan Proud
    @spry-rproud
    Why?
    Flavio W. Brasil
    @fwbrasil
    there isn’t a way to deserialize the enum without the user specifying the enum object
    json4s requires an implicit formatter for the enum, right?
    Ryan Proud
    @spry-rproud
    Yes
    Flavio W. Brasil
    @fwbrasil
    it isn’t possible to use the same approach for activate
    because there isn’t a way to fail at compilation time
    it would be possible to fail at runtime if the enum serializer is not provided, but i’m not sure it is a good approach
    Flavio W. Brasil
    @fwbrasil
    i was thinking, does it work if you change the enum to be:
    object Status extends Enumeration {
      case class Status(name: String) extends Val(name)
      val ACTIVE: Value = Status("active")
      val INACTIVE: Value = Status("inactive")
    }
    try Value or Val
    Ryan Proud
    @spry-rproud
    No, that just makes name protected