Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Paul Draper
    @pauldraper
    ^ 2.12 upgrade
    Gregg Hernandez
    @gregghz
    Looks great. You should merge it
    Gregg Hernandez
    @gregghz
    Does anyone know of how to generate the API docs?
    Paul Draper
    @pauldraper
    sbt doc:compile I'm guessing Mark copied that to the ghpages branch
    Gregg Hernandez
    @gregghz
    sounds like it. thanks.
    Gregg Hernandez
    @gregghz
    lucidsoftware/relate#43
    this should be ready to merge.
    do we need this anymore?
    nice.
    Mark de Jong
    @Fristi
    Hello
    Anyone here?
    I've got problems with #44 , anyone could be of help?
    Gregg Hernandez
    @gregghz
    Hi @Fristi can you try that again without the .toString() call on the millis?
    Mark de Jong
    @Fristi
    @gregghz It throws the same error

    I also tried this:

      implicit def fromFiniteDuration(state: FiniteDuration): SingleParameter =
        new StringParameter(s"${state.toMinutes} minutes")
    
          val stmt = sql"SELECT session_id, user_uuid, device_uuid FROM sessions WHERE session_id = $sessionId AND AGE(now(), created_at) <= interval $sessionDuration"
          println(s"sql: ${stmt.statementString}")
    
            stmt
            .asList(decoder)
            .headOption

    Which throws

    sql: HikariProxyPreparedStatement@61506193 wrapping SELECT session_id, user_uuid, device_uuid FROM sessions WHERE session_id = '$2a$10$ES/P9qy1TrAuah7dVuZEeehL/oeVJ5Sm/WSFYh0JO4AfL04SjyKg.' AND AGE(now(), created_at) <= interval '5 minutes'
    [ERROR][17:09:20.676][application][C:] -
    
    ! @736ajg8kd - Internal server error, for (POST) [/api/v0.1/user/exchange] ->
    
    play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[PSQLException: ERROR: syntax error at or near "$2"
      Position: 118]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
        at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70)
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40)
        at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248)
        at scala.concurrent.Promise$class.complete(Promise.scala:55)
        at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:415)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
      Position: 118
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
        at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
        at com.lucidchart.open.relate.NormalStatementPreparer$class.results(StatementPreparer.scala:90)
        at com.lucidchart.open.relate.Sql$$anon$2.results(SqlQuery.scala:285)
        at com.lucidchart.open.relate.StatementPreparer$class.execute(StatementPreparer.scala:20)
        at com.lucidchart.open.relate.Sql$$anon$2.execute(SqlQuery.scala:285)
        at com.lucidchart.open.relate.Sql$class.asList(SqlQuery.scala:441)
        at com.lucidchart.open.relate.interp.InterpolatedQuery.asList(InterpolatedQuery.scala:8)
        at com.next.user.dao.impl.SessionDao$$anonfun$findBySessionId$1.apply(SessionDao.scala:46)
        at com.next.user.dao.impl.SessionDao$$anonfun$findBySessionId$1.apply(SessionDao.scala:41)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:155)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:149)
        at com.next.user.dao.impl.SessionDao$$anonfun$DbFuture$1.apply(SessionDao.scala:20)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
        at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
    Gregg Hernandez
    @gregghz
    thanks, I'm looking into the UUID issue right now. When I get some extra time I'll see what I can do about this one
    Mark de Jong
    @Fristi
    I've tried to run the query printed above SELECT session_id, user_uuid, device_uuid FROM sessions WHERE session_id = '$2a$10$ES/P9qy1TrAuah7dVuZEeehL/oeVJ5Sm/WSFYh0JO4AfL04SjyKg.' AND AGE(now(), created_at) <= interval '5 minutes' in psequel (postgres mac client)
    That works fine
    Gregg Hernandez
    @gregghz
    ok cool. I just pushed a fix for the UUID issue for reading data from a column. But there's a related issue where you can't interpolate UUIDs in postgres: lucidsoftware/relate#47
    here's the fix for reading data: lucidsoftware/relate#46
    Mark de Jong
    @Fristi
    Thanks :-)
    Any clue what the problem could be with the date query ?
    Gregg Hernandez
    @gregghz
    I'm not sure yet, I haven't had a chance to test that one
    Gregg Hernandez
    @gregghz
    @Fristi The column type is an interval for lucidsoftware/relate#44, right?
    these postgres issue make me think we might need separate modules for databases with column types that go beyond what jdbc assumes are available. Writing an interval to postgres requires a call to setObject while passing a PGInterval. I think I'm going to create a sub-project (relate-postgres or something) that deals with these kinds of unique types for postgres. Does anyone have any thoughts on this?
    Gregg Hernandez
    @gregghz
    Also, fwiw, I think it was a mistake to make a uuid column parser since now it's super overloaded and has pretty weird semantics that only partially even map to what lucid does with it. I believe we only ever read a UUID from a byte array or blob column type. We should have just used a col parser for that type and then transformed to UUID in code. It would have made support the postgres UUID column easier
    Mark de Jong
    @Fristi
    The type of the column (created_at) is date time. You can write expressions in WHERE clauses like I did: AGE(now(), created_at) <= interval '5 minutes'
    Quill/Slick uses typeclasses to do different type conversions
    Might be interesting for you as well
    Mark de Jong
    @Fristi
    datetime = timestamp
    Gregg Hernandez
    @gregghz
    Typeclasses would be perfect except the only way I've found to use them in a string context like sql is via shapeless. It had a pretty significant negative performance impact.
    Gregg Hernandez
    @gregghz
    @Fristi thanks for that info. I believe the problem could be solved by creating an implicit PGInterval => Parameter and then instead of trying to interpolate a Long, with sql"... AGE(now(), created_at) <= interval '$long milliseonds' you could just interpolate the full PGInterval: sql"... AGE(now(), created_at) <= $pgInterval" (you might need the interval function too, I'm not sure). I haven't had a chance to test this. I will as soon as I can but feel free to give it a shot in the meantime.
    Gregg Hernandez
    @gregghz
      implicit class PGIntervalParameter(value: PGInterval) extends SingleParameter {
        protected def set(stmt: PreparedStatement, i: Int) = stmt.setObject(i, value)
      }
    And then you can query like this:
    val interval = new PGInterval(s"${sessionDuration.toMillis} milliseconds")
    sql"SELECT session_id, user_uuid, device_uuid FROM sessions WHERE session_id = $sessionId AND AGE(now(), created_at) < $interval"
    Gregg Hernandez
    @gregghz
    lucidsoftware/relate#48
    Mark de Jong
    @Fristi
    Thanks for your answer @gregghz.
    I'll try soon
    And report back :-)
    Mark de Jong
    @Fristi
    That works, I've reported it as well in the issue
    Thanks for your support @gregghz
    Gregg Hernandez
    @gregghz
    👍
    winry
    @fwrq41251
    Any one know how to split a sql into many lines?
    Use "+" to concat strings bring compile error
    Mark Siebert
    @msiebert
    http://lucidsoftware.github.io/relate/docs/writing-queries.html#query-composition suggests that using + with two sql"" strings should work. Is that not working for you?
    also that header on the documentation is all messed up @gregghz
    you should fix it with your mad css skillz
    James Judd
    @jjudd
    I'm pretty sure that sql"""<stuff>""" should also work, so you can just use a multiline string.
    winry
    @fwrq41251
    @jjudd works 👍
    Mark Siebert
    @msiebert
    oh yeah, I totally misunderstood your question. Sorry about that