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
    does this query return the entityes with custom id as well?
              query {
                (e: Entity) => where()
              }
    Ryan Proud
    @spry-rproud
    I don't have any currently. I can try and run some tests, but I was getting an error with the commented portion. I think because the context wasn't managing any EntityWithCustomID classes.
    Also when I tried (e: BaseEntity) => where() I was getting some odd behaviour. It was only picking up a few of our entities.
    Flavio W. Brasil
    @fwbrasil
    yeah, that’s the problem
    Ryan Proud
    @spry-rproud
    @fwbrasil I'm also seeing the issue again where I'm seeing FK constraint errors because entities aren't getting persisted to the database in time. Is there any guarantee that distinct transactions should be persisted in order?
    Ryan Proud
    @spry-rproud
    @fwbrasil It seems like deleteCascade may also be broken.
    Flavio W. Brasil
    @fwbrasil
    yeah, same bug
    about the tests x transactions, the transactions should be persisted in the same order that they happen
    Ryan Proud
    @spry-rproud
    Yeah, I think that was an issue with my code. Or just a misunderstanding on the test strategies.
    Flavio W. Brasil
    @fwbrasil
    could you open a github issue?
    with both problems (same root cause)
    Ryan Proud
    @spry-rproud
    Sure. Any ideas on what might be a work around because I've realized mine doesn't work because of constraint issues which I was trying to get around with deleteCascade?
    Flavio W. Brasil
    @fwbrasil
    humm, i’m not sure there is a workaround
    Ryan Proud
    @spry-rproud
    For entity lifecycle is there any context that information can be stashed in (ie. user information), so beforeInsert/Update can be used for auditing purposes?
    Ryan Proud
    @spry-rproud
    @fwbrasil Also is it possible to disable lifecycle methods while migrations are running?
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud are you using async persistence? If not, you could use a ThreadLocal
    to hold the user information
    Ryan Proud
    @spry-rproud
    Ok, thanks
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud about the lifecycle methods, there isn’t a built-in way to disable it
    Ryan Proud
    @spry-rproud
    Ok thanks. I just had a migration inserting data and it was causing a bit of havoc on startup. I just re-ordered it to get around the issue.
    Flavio W. Brasil
    @fwbrasil
    cool
    Marin Vila
    @rinmalavi
    Hi, I have a simple question.. :)
    Is it possible to use a class that extends Entity outside transactional
    Flavio W. Brasil
    @fwbrasil
    @rinmalavi it is possible only to read outside of transactional
    but it won’t provide any consistency guarantees
    Marin Vila
    @rinmalavi
    Guess that is actually good, but will introduce some code duplication,
    thanks!
    Marin Vila
    @rinmalavi
    do I need any special import in order to use .col method?
    Marin Vila
    @rinmalavi
    I am trying to make https://github.com/fwbrasil/activate/blob/master/activate-docs/query.md#slick-queries work. Get 'col is not member of String' Error.
    I see its in SlickQueryContext trait and i have it imported with ActivateContext, but i can't call it on id property.
    Ryan Proud
    @spry-rproud
    import context.driver.simple_
    Marin Vila
    @rinmalavi
    thanks, that worked :+1:, tho idea is complaining about execute
    now, however, I have RequiredTransactionException
    this is what i am trying to do:
    case class A(a: String, b: String)extends  Entity
    case class B(a: A, c: String) extends  Entity
    
    val a =(for {
      a <- SlickQuery[A]
      b <- SlickQuery[B] if b.a.col === a.col
    } yield (b.col)).execute
    Ryan Proud
    @spry-rproud
    wrap in transactional {}
    Marin Vila
    @rinmalavi
    oh, ofc, thought they dont need those
    Marin Vila
    @rinmalavi
    java.lang.InternalError: Malformed class name :sparkles:
    works nicely tho, except the part the idea doesn't compile
    Marin Vila
    @rinmalavi

    I have one more, hope i am not disturbing too much :-)
    I need to find an average over field for a certain detail
    Basically i want to do this

      case class A(a: String, b: String)extends  Entity
      case class B(a: A, c: String, f: Int) extends  Entity
    
      val a = (for {
        a <- SlickQuery[A].rightJoin(SlickQuery[B]).on(_.col === _.a.col)
      } yield a).groupBy(_._2.a.col).map { case (n, g) => (n, g.map {_._2.f}.avg) }.execute

    Tried several combinations usually get:
    Trying to reassign node type -- nodeTyped() may only be called on freshly constructed nodes

    ....
    (SlickQueryContext.scala:137)
    [error] net.fwbrasil.activate.slick.SlickQueryContext$QueryRun
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun̲$execute$1.app: anonfun$execute$1.apply(SlickQueryContext.scala:137)
    [error] net.fwbrasil.activate.slick.SlickQueryContext$QueryRun
    anonfun$execute$1.apply(SlickQueryContext.scala:136)
    [error] net.fwbrasil.activate.slick.SlickQueryContext$$anon$1.withSession(SlickQueryContext.scala:89)
    [error] net.fwbrasil.activate.slick.SlickQueryContext$QueryRun.execute(SlickQueryContext.scala:135)
    Ryan Proud
    @spry-rproud

    @fwbrasil Is there any way to provide hints to ensure that statements generated in the transaction are executed in a specific order? We're running into an issue, where our entity design looks cyclical, but the actual data itself is not. It appears that this is causing FK constraint errors. ie.

    class Foo(var name: String, var bar1: Bar, var bar2: Bar) extends Entity
    class Bar(var name: String, var foo: Foo) extends Entity
    
    transactional {
        val bar1 = new Bar("bar1", null)
        val bar2 = new Bar("bar2", null)
    
        val foo = new Foo("foo", bar1, bar2)
    }

    This transaction is occasionally (it does appear to be random) failing because the ids for bar1 and bar2 do not exist yet in the database. Any of instance of Bar that is referenced by Foo should always have a null foo reference.

    qdx
    @qdx
    Just trying out Activate, got into a little problem querying datetime from mysql database, here's the code:
    ```
    class Ratings(var name: String,
                  var f_rating_id: Int,
                  var deleted: Boolean,
                  var created_at: Option[DateTime],
                  var updated_at: Option[Date],
                  var h_rating_id: Int) extends Entity
    
    object ExampleMain extends App {
      transactional {
        val ratings = select[Ratings] where (_.id :== 4)
        println(ratings.map{r => s"${r.name}, ${r.created_at.get}, ${r.updated_at.get}"})
      }
    }
    The out put I get is:
    List(TV-Y,1969-12-31T16:00:02.009-08:00,4,Wed Dec 31 16:00:02 PST 1969)
    where the date doesn't seem to be right, they are not from year 1969 in the database.
    Can anyone help?
    Clayton Silva
    @claytonsilva
    @fwbrasil i want to add redshift support on activate, but i broke the build on polyglot teste :( , do you can help me?
    Pawel
    @odwrotnie
    hi!
    Flavio W. Brasil
    @fwbrasil
    hi!
    @claytonsilva focus on having the tests for redshift passing and create a pull request, i can help fixing the other tests
    Ryan Proud
    @spry-rproud
    @fwbrasil Should SlickQuery work with custom normalize functions? It's using incorrect relation names when using underscoreSeparated.
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud I don’t remember the implementation, but it should
    it is probably a bug