Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ryan Proud
    @spry-rproud
    Nevermind, found the open issue.
    Ryan Proud
    @spry-rproud
    Are there any known issues with reinitializeContext? Or anything else required to clean the live cache? When calling it I'm still getting old data from queries also in the logs I'm not seeing anything about the context being reloaded, just HikariPool cleanup, which is likely just coincidental. I'm using 1.7.
    Flavio W. Brasil
    @fwbrasil
    it is an unknown issue
    could you open an issue and describe your use-case?
    Ryan Proud
    @spry-rproud
    def reinitializeContext =
            logInfo("reinitializing context " + contextName) {
                clearCachedQueries
                liveCache.reinitialize
                storages.foreach(_.reinitialize)
                reinitializeIdGenerators
                unloadIndexes
            }
    I'm not sure how Grizzled logger works, but is the function block dependant on the log level?
    Flavio W. Brasil
    @fwbrasil
    yep, it is info
    Ryan Proud
    @spry-rproud
    Does the STM allow for transactional blocks to execute concurrently?
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud yep
    Ryan Proud
    @spry-rproud
    Are there any examples available to demonstrate this. I'm having issues where all my transactions are blocking until the previous one completes.
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud http://databen.ch/
    Ryan Proud
    @spry-rproud
    Is there a way to mark an entity as "dirty" without modifying, so we can block on reads?
    Ryan Proud
    @spry-rproud
    Is there any support for postgresql array or json types?
    Ryan Proud
    @spry-rproud
    @fwbrasil Hey do you have some time to answer a few questions?
    Flavio W. Brasil
    @fwbrasil
    @spry-rproud hey
    yeah, sorry I forgot to answer the previous ones
    go for it
    Ryan Proud
    @spry-rproud
    No worries, we wondering if it's possible to override the Postgres driver used by the context.
    Flavio W. Brasil
    @fwbrasil
    use another postgres jdbc driver?
    Ryan Proud
    @spry-rproud
    Yes, we're trying to use slick-pg to do some queries on json columns and it appears to override the slick PostgresDriver.
    object MyPostgresDriver extends PostgresDriver
                                with PgJson4sSupport
                                with array.PgArrayJdbcTypes {
        /// for json support
        override val pgjson = "jsonb"
        type DOCType = text.Document
        override val jsonMethods = org.json4s.native.JsonMethods
    
        override lazy val Implicit = new Implicits with JsonImplicits
        override val simple = new Implicits with SimpleQL with JsonImplicits {
          implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
        }
    
        val plainImplicits = new Implicits with Json4sJsonPlainImplicits
      }
    Flavio W. Brasil
    @fwbrasil
    I see
    let me check
    how do you create your persistence context?
    I think you can override lazy val driver = MyPostgresDriver
    Ryan Proud
    @spry-rproud
    object myContext extends ActivateContext with SlickQueryContext {
        val storage = new PooledJdbcRelationalStorage {
                val jdbcDriver = "org.postgresql.Driver"
                val user = Some("postgres")
                val password = None
                val url = "jdbc:postgresql://127.0.0.1/json-test"
                val dialect = postgresqlDialect
            }
    }
    Flavio W. Brasil
    @fwbrasil
    object myContext extends ActivateContext with SlickQueryContext {
        override lazy val driver = MyPostgresDriver
        val storage = new PooledJdbcRelationalStorage {
                val jdbcDriver = "org.postgresql.Driver"
                val user = Some("postgres")
                val password = None
                val url = "jdbc:postgresql://127.0.0.1/json-test"
                val dialect = postgresqlDialect
            }
    }
    Ryan Proud
    @spry-rproud
    Ok, that may work. I'll keep looking into it. Thanks.
    Flavio W. Brasil
    @fwbrasil
    np :)
    Ryan Proud
    @spry-rproud
    Is it possible to override the default DateStorageValue for postgresql? (ie. "timestamptz")
    Flavio W. Brasil
    @fwbrasil
    you can override the toSqlDdl method
    new postgresqlDialect(string => "\"" + string + "\””, string => string) {
       override def toSqlDdl(storageValue: StorageValue): String =
            storageValue match {
                case value: DateStorageValue =>
                      “timestamptz”
                case other => super.toSqlDdl(other)
           }
    }
    @spry-rproud ^
    Ryan Proud
    @spry-rproud
    Thanks. That seems to work great.
    Flavio W. Brasil
    @fwbrasil
    :clap:
    Ryan Proud
    @spry-rproud
    Is it possible to have a context ignore certain migrations? I'm having some issues where H2 is having issues with a customScript migration which isn't entirely necessary for tests.
    Flavio W. Brasil
    @fwbrasil
    maybe check the context storage type in the custom script?
    if(context.storage.dialect != h2)
    Ryan Proud
    @spry-rproud
    Does TransientMemoryStorage not maintain StorageVersion?
    Flavio W. Brasil
    @fwbrasil
    it should maintain, I think
    let me check
    yeah, it should maintain the StorageVersion and run the migations
    but it looses the data when restarting, since it is transient
    Ryan Proud
    @spry-rproud
    We're having an issue with the cleanDatabaseStrategy for testing. It doesn't appear to be cleaning all our tables. I'm only seeing a delete against a single table when monitoring the postgres log. Any ideas on what could cause this?
    @fwbrasil
    Ryan Proud
    @spry-rproud
    @fwbrasil It looks like it's because most of our entities extend EntityWithGeneratedId.
    Ryan Proud
    @spry-rproud
    I've created a custom strategy for now to get around it. Is this a bug or am I missing something?
    Flavio W. Brasil
    @fwbrasil
    it looks to be a bug
    what is the workaround?
    Ryan Proud
    @spry-rproud
    I just created another test strategy which also deletes all EntityWithGeneratedId[AnyVal].
    object customCleanDatabaseStrategy extends ActivateTestStrategy {
    
      def runTest[R](f: => R)(implicit ctx: ActivateContext) = {
        prepareDatabase
        ctx.transactional(f)
      }
    
      def runTestAsync[R](f: => R)(implicit ctx: ActivateContext): R = {
        prepareDatabase
        await(ctx.asyncTransactional(f))
      }
      def runTestAsyncChain[R](f: TransactionalExecutionContext => Future[R])(implicit ctx: ActivateContext): R = {
        prepareDatabase
        await(ctx.asyncTransactionalChain(f(_)))
      }
    
      private def prepareDatabase(implicit ctx: ActivateContext) = {
        cleanDatabase
        ctx.reinitializeContext
      }
    
      private def cleanDatabase(implicit ctx: ActivateContext) = {
        import ctx._
        storage match {
          case storage: TransientMemoryStorage =>
            storage.directAccess.clear()
          case other =>
            transactional {
              delete {
                (e: Entity) => where()
              }
              delete {
                (e: EntityWithGeneratedID[AnyVal]) => where()
              }
    //          delete {
    //            (e: EntityWithCustomID[AnyVal]) => where()
    //          }
            }
        }
      }
    }
    Flavio W. Brasil
    @fwbrasil
    does this query return the entityes with custom id as well?
              query {
                (e: Entity) => where()
              }