Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Mark de Jong
    @Fristi
    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
    Drew O'Kane
    @drewokane
    hi, I'm having a bit of trouble with dates in a query. I'm attempting to do something like:
    val dateFormat = "YYYY-MM-DD HH:mm:ss"
    val start = new DateTime(2016, 1, 1, 0, 1, 1).toString(dateFormat)
    sql"select * from measurement where end_interval >= $start limit 10"
    Gregg Hernandez
    @gregghz
    is that a joda date time?
    Drew O'Kane
    @drewokane
    yes it is
    Gregg Hernandez
    @gregghz
    there's no interpolator for that
    you also don't want to do toString on it like that
    do this:
    val start = new DateTime(2016, 1, 1, 0, 1, 1)
    sql"select * from measurement where end_interval >= ${start.toDate} limit 10"
    we never created a parameter for interpolation of org.joda.time.DateTime because we didn't want to add dependencies to relate. We would probably accept a PR adding direct support to DateTime via a module the way we have postgres support via a module though
    Drew O'Kane
    @drewokane
    hmmm, seems simple enough
    doesn't work though:
    scala> sql"select * from measurement where end_interval >= ${start.toDate} limit 10"
    res25: com.lucidchart.relate.InterpolatedQuery = select * from measurement where end_interval >= ? limit 10
    oh wait, nvm
    went through
    thanks @gregghz
    Gregg Hernandez
    @gregghz
    np!
    Murphy Randle
    @mrmurphy
    Hey friends, I'm just getting into SQL with Scala, and I'm using Relate. I'm running into an interesting situation where I've got this query:
    delete from management where key in (?);
    the actual source looks like this:
    sql"delete from $table where key in ($deleteKeys);"
    and $deletedKeys contains a string value
    in this case foo
    Gregg Hernandez
    @gregghz
    what is table? you might be subject to an sql syntax error with that usage
    Murphy Randle
    @mrmurphy
    the strange behavior I'm seeing is that foo will sometimes be deleted, and sometimes it will remain while only its content is deleted
    it's nondeterministic
    oh interesting, it's a custom table
    I haven't run into any errors so far
    Gregg Hernandez
    @gregghz
    Hmm, okay. Usually interpolating table names is a mistake. It will get written out as delete from “management” where …. Those quotes usually are a syntax error, that’s why I brought it up
    anyway, your issue: what do you mean by “only its content is deleted”?
    Murphy Randle
    @mrmurphy
    that makes sense. I'm able to avoid the quoting by calling .toSql on the table name string
    Gregg Hernandez
    @gregghz
    :thumbsup: yeah, .toSql was what I was going to suggest, glad that’s working okay
    Murphy Randle
    @mrmurphy
    yeah, that's what's strange, usually all of the columns on the row will be set to NULL
    and the whole row will remain
    but sometimes the row will be removed
    Gregg Hernandez
    @gregghz
    interesting …. you’re using mysql? which driver? I’d make sure whatever sql driver you’re using for your DB is up to date
    Murphy Randle
    @mrmurphy
    I've checked that it's not just my client caching data by loading up psql
    Using postgres, just started this project last week, so it's the latest driver from maven central
    libraryDependencies += "org.postgresql" % "postgresql" % "42.2.2.jre7"
    libraryDependencies += "com.lucidchart" %% "relate" % "2.0.1"
    I think?
    Gregg Hernandez
    @gregghz
    hmm, I’m not sure what’s going on there. What’s the full code that runs the sql? are you calling .update() or execute()? or what?
    Murphy Randle
    @mrmurphy
          val delete = sql"delete from ${bucket.toSql} where key in ($deleteKeys);"
          println(s"DEBUG: ${delete} $deleteKeys")
          delete.execute
    and. usually if there's a sql error an error will be thrown