-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80bc0d9
commit 53918e5
Showing
7 changed files
with
99 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
quill-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/sync/jdbc/AddressSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pl.jozwik.quillgeneric.sync.jdbc | ||
|
||
import java.time.Instant | ||
|
||
import pl.jozwik.quillgeneric.sync.jdbc.repository.AddressRepository | ||
import pl.jozwik.quillgeneric.model.{ Address, AddressId } | ||
import org.scalatest.TryValues._ | ||
|
||
trait AddressSuite extends AbstractJdbcSpec { | ||
private val repository = new AddressRepository(ctx) | ||
|
||
"AddressSuite " should { | ||
"Call crud operations " in { | ||
val id = AddressId(1) | ||
val entity = Address(id, "Country", "City") | ||
val address = repository.createOrUpdateAndRead(entity).success.value | ||
address shouldBe entity | ||
val a = repository.searchUpdateAfter(Instant.now).success.value | ||
a shouldBe empty | ||
repository.updateAndRead(address.copy(updated = Option(Instant.now))) | ||
val b = repository.searchUpdateAfter(Instant.EPOCH).success.value | ||
b should not be empty | ||
repository.deleteAll shouldBe Symbol("success") | ||
} | ||
} | ||
} |
14 changes: 7 additions & 7 deletions
14
quill-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/sync/jdbc/QuillCrudJdbcSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package pl.jozwik.quillgeneric.sync.jdbc | ||
|
||
class QuillCrudJdbcSpec | ||
extends Cell4dSuite | ||
with PersonRepositoryNotGeneratedIdSuite | ||
with PersonCustomRepositorySuite | ||
with PersonRepositorySuite | ||
with ConfigurationRepositorySuite | ||
with SaleRepositorySuite | ||
class QuillCrudJdbcSpec extends AddressSuite | ||
// with PersonRepositoryNotGeneratedIdSuite | ||
// with PersonCustomRepositorySuite | ||
// with PersonRepositorySuite | ||
// with ConfigurationRepositorySuite | ||
// with SaleRepositorySuite | ||
// with Cell4dSuite |
22 changes: 22 additions & 0 deletions
22
...rc/test/scala/pl/jozwik/quillgeneric/sync/jdbc/repository/AbstractAddressRepository.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package pl.jozwik.quillgeneric.sync.jdbc.repository | ||
|
||
import java.time.Instant | ||
|
||
import io.getquill.NamingStrategy | ||
import io.getquill.context.sql.idiom.SqlIdiom | ||
import pl.jozwik.quillgeneric.model.{ Address, AddressId } | ||
import pl.jozwik.quillgeneric.quillmacro.sync.JdbcRepositoryWithGeneratedId | ||
|
||
import scala.util.Try | ||
|
||
trait AbstractAddressRepository[D <: SqlIdiom, N <: NamingStrategy] extends JdbcRepositoryWithGeneratedId[AddressId, Address, D, N] { | ||
|
||
def searchUpdateAfter(updated: Instant): Try[Seq[Address]] = | ||
Try { | ||
import context._ | ||
val q = dynamicSchema | ||
.filter(a => quote(a.updated > lift(Option(updated)))) | ||
run(q) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ThisBuild / version := "0.9.1-SNAPSHOT" | ||
ThisBuild / version := "0.9.1" |