Skip to content

Commit

Permalink
merge #551's changes, jump to v0.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tminglei committed Apr 17, 2022
1 parent 851a614 commit 8ef2586
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,44 +194,44 @@ Install
-------
To use `slick-pg` in [sbt](http://www.scala-sbt.org/ "slick-sbt") project, add the following to your project file:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg" % "0.20.3"
```

> If you need `joda-time` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_joda-time" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_joda-time" % "0.20.3"
```

> If you need `jts` geom support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_jts" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_jts" % "0.20.3"
or
libraryDependencies += "com.github.tminglei" %% "slick-pg_jts_lt" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_jts_lt" % "0.20.3"
```

> If you need `json4s` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_json4s" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_json4s" % "0.20.3"
```

> If you need `play-json` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_play-json" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_play-json" % "0.20.3"
```

> If you need `spray-json` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_spray-json" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_spray-json" % "0.20.3"
```

> If you need `argonaut json` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_argonaut" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_argonaut" % "0.20.3"
```

> If you need `circe json` support, pls append dependency:
```scala
libraryDependencies += "com.github.tminglei" %% "slick-pg_circe-json" % "0.20.2"
libraryDependencies += "com.github.tminglei" %% "slick-pg_circe-json" % "0.20.3"
```


Expand All @@ -240,7 +240,7 @@ Or, in [maven](http://maven.apache.org/ "maven") project, you can add `slick-pg`
<dependency>
<groupId>com.github.tminglei</groupId>
<artifactId>slick-pg_2.12</artifactId>
<version>0.20.2</version>
<version>0.20.3</version>
</dependency>
<!-- other addons if necessary -->
...
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lazy val commonSettings = Seq(
organizationName := "slick-pg",
organization := "com.github.tminglei",
name := "slick-pg",
version := "0.20.2",
version := "0.20.3",

scalaVersion := scala213,
crossScalaVersions := Seq(scala213, scala212, scala211),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ trait PgSearchExtensions extends JdbcTypesComponent { driver: PostgresProfile =>
val Or = new SqlOperator("||")
val Negate = new SqlOperator("!!")
val Contains = new SqlOperator("@>")
val Phrase = new SqlOperator("<->")

val GetCurrTsConfig = new SqlFunction("get_current_ts_config")
val ToTsQuery = new SqlFunction("to_tsquery")
Expand Down Expand Up @@ -138,6 +139,8 @@ trait PgSearchExtensions extends JdbcTypesComponent { driver: PostgresProfile =>
def !! = SearchLibrary.Negate.column[TQ](c.toNode)
def @>[P2, R](e: Rep[P2])(implicit om: o#arg[TQ, P2]#to[Boolean, R]) =
om.column(SearchLibrary.Contains, c.toNode, e.toNode)
def <->[P2, R](e: Rep[P2])(implicit om: o#arg[TQ, P2]#to[TQ, R]) =
om.column(SearchLibrary.Phrase, c.toNode, e.toNode)

def numNode = SearchLibrary.NumNode.column[Int](c.toNode)
def queryTree = SearchLibrary.QueryTree.column[String](c.toNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Supported Search Oper/Functions
-------------------------------

| Slick Oper/Function | PG Oper/Function | Description | Example | Result |
| ------------------- | ---------------- | -------------------------------- | -------------------------------------- | ----------- |
|---------------------|------------------| -------------------------------- | -------------------------------------- | ----------- |
| tsQuery | to_tsquery | normalize words and convert to tsquery | to_tsquery('english', 'The & Fat & Rats') | 'fat' & 'rat' |
| tsVector | to_tsvector | reduce document text to tsvector | to_tsvector('english', 'The Fat Rats') | 'fat':2 'rat':3 |
| @@ | @@ | tsvector matches tsquery ? | to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat') | t |
| @+ | &#124;&#124; | concatenate tsvectors | 'a:1 b:2'::tsvector &#124;&#124; 'c:1 d:2 b:3'::tsvector | 'a':1 'b':2,5 'c':3 'd':4 |
| @& | && | AND tsquerys together | 'fat &#124; rat'::tsquery && 'cat'::tsquery | ( 'fat' &#124; 'rat' ) & 'cat' |
| <-> | <-> | Constructs a phrase query, which matches if the two input queries match at successive lexemes. | to_tsquery('fat') <-> to_tsquery('rat') | 'fat' <-> 'rat' |
| @&#124; | &#124;&#124; | OR tsquerys together | 'fat &#124; rat'::tsquery &#124;&#124; 'cat'::tsquery | ( 'fat' &#124; 'rat' ) &#124; 'cat' |
| !! | !! | negate a tsquery | !! 'cat'::tsquery | !'cat' |
| @> | @> | tsquery contains another ? | 'cat'::tsquery @> 'cat & rat'::tsquery | f |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class PgSearchSupportSuite extends AnyFunSuite with PostgresContainer {

val testRec1 = TestBean(33L, "fat cat ate rat", TsVector("'ate' 'cat' 'fat' 'rat'"), "")
val testRec2 = TestBean(37L, "cat", TsVector("'ca'"), "fat")
val testRec3 = TestBean(38L, "mike rose", TsVector("'mike' 'rose'"), "")
val testRec4 = TestBean(39L, "mike and rose", TsVector("'mike' 'and' 'rose'"), "")

test("Text search Lifted support") {
Await.result(db.run(
DBIO.seq(
Tests.schema create,
///
Tests forceInsertAll List(testRec1, testRec2)
Tests forceInsertAll List(testRec1, testRec2, testRec3, testRec4)
).andThen(
DBIO.seq(
// get_current_ts_config
Expand Down Expand Up @@ -62,13 +64,17 @@ class PgSearchSupportSuite extends AnyFunSuite with PostgresContainer {
),
// @>
Tests.filter(r => plainToTsQuery(r.text, Some("english")) @> toTsQuery(r.comment, Some("english"))).sortBy(_.id).to[List].result.map(
r => assert(List(testRec1) === r)
r => assert(List(testRec1, testRec3, testRec4).map(_.id) === r.map(_.id))
),
Tests.filter(r => phraseToTsQuery(r.text, Some("english")) @> toTsQuery(r.comment, Some("english"))).sortBy(_.id).to[List].result.map(
r => assert(List(testRec1) === r)
r => assert(List(testRec1, testRec3, testRec4).map(_.id) === r.map(_.id))
),
Tests.filter(r => webSearchToTsQuery(r.text, Some("english")) @> toTsQuery(r.comment, Some("english"))).sortBy(_.id).to[List].result.map(
r => assert(List(testRec1) === r)
r => assert(List(testRec1, testRec3, testRec4).map(_.id) === r.map(_.id))
),
// <->
Tests.filter(r => toTsVector(r.text, Some("english")) @@ (tsQuery("mike".bind) <-> tsQuery("rose".bind))).sortBy(_.id).to[List].result.map(
r => assert(List(testRec3) === r)
),
// length
Tests.filter(_.id === 33L).map(r => toTsVector(r.text).length).result.head.map(
Expand Down

0 comments on commit 8ef2586

Please sign in to comment.