-
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
Showing
79 changed files
with
633 additions
and
80 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
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...llgeneric/quillmacro/sync/CrudMacro.scala → ...k/quillgeneric/quillmacro/CrudMacro.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
2 changes: 1 addition & 1 deletion
2
...eneric/quillmacro/quotes/DateQuotes.scala → .../quillgeneric/quillmacro/DateQuotes.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
File renamed without changes.
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
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
macro-quill/src/main/scala/pl/jozwik/quillgeneric/quillmacro/WithUpdate.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,5 @@ | ||
package pl.jozwik.quillgeneric.quillmacro | ||
|
||
trait WithUpdate[UPDATE] { | ||
type U = UPDATE | ||
} |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
...src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/sync/CassandraRepository.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,19 @@ | ||
package pl.jozwik.quillgeneric.quillmacro.cassandra.sync | ||
|
||
import io.getquill.{ CassandraSyncContext, NamingStrategy } | ||
import pl.jozwik.quillgeneric.quillmacro.cassandra.sync.CassandraRepository.CassandraContextDateQuotes | ||
import pl.jozwik.quillgeneric.quillmacro.sync.{ CrudWithContext, SyncRepository } | ||
import pl.jozwik.quillgeneric.quillmacro.{ CompositeKey, DateQuotes, WithId, WithUpdate } | ||
|
||
object CassandraRepository { | ||
type CassandraContextDateQuotes[N <: NamingStrategy] = CassandraSyncContext[N] with CrudWithContext[Unit] with DateQuotes | ||
} | ||
|
||
trait CassandraRepository[K, T <: WithId[K], N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Unit] { | ||
protected val context: CassandraContextDateQuotes[N] | ||
|
||
protected def dynamicSchema: context.DynamicEntityQuery[T] | ||
|
||
} | ||
|
||
trait CassandraMonixRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraRepository[K, T, N] |
11 changes: 11 additions & 0 deletions
11
quill-cassandra-macro/src/test/resources/application.properties
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,11 @@ | ||
cassandra.keyspace=demo | ||
cassandra.preparedStatementCacheSize=1000 | ||
cassandra.session.contactPoint=127.0.0.1 | ||
cassandra.session.withPort=9142 | ||
cassandra.session.queryOptions.consistencyLevel=LOCAL_QUORUM | ||
cassandra.session.withoutMetrics=true | ||
cassandra.session.withoutJMXReporting=false | ||
cassandra.session.credentials.0=root | ||
cassandra.session.credentials.1=pass | ||
cassandra.session.maxSchemaAgreementWaitSeconds=1 | ||
cassandra.session.addressTranslator=com.datastax.driver.core.policies.IdentityTranslator |
69 changes: 69 additions & 0 deletions
69
quill-cassandra-macro/src/test/resources/scripts/create.cql
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,69 @@ | ||
CREATE TABLE IF NOT EXISTS ADDRESS | ||
( | ||
ID UUID PRIMARY KEY, | ||
COUNTRY TEXT, | ||
CITY TEXT, | ||
STREET TEXT, | ||
BUILDING_NUMBER TEXT, | ||
LOCAL_NUMBER TEXT, | ||
UPDATED TIMESTAMP | ||
); | ||
/** | ||
CREATE TABLE IF NOT EXISTS PERSON | ||
( | ||
ID INT NOT NULL, | ||
FIRST_NAME VARCHAR(50) NOT NULL, | ||
LAST_NAME VARCHAR(20) NOT NULL, | ||
BIRTH_DATE DATE, | ||
ADDRESS_ID INT DEFAULT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS PERSON2 | ||
( | ||
ID INT NOT NULL AUTO_INCREMENT, | ||
FIRST_NAME VARCHAR(50) NOT NULL, | ||
LAST_NAME VARCHAR(20) NOT NULL, | ||
BIRTH_DATE DATE, | ||
ADDRESS_ID INT DEFAULT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS PERSON3 | ||
( | ||
ID INT NOT NULL AUTO_INCREMENT, | ||
FIRST_NAME VARCHAR(50) NOT NULL, | ||
LAST_NAME VARCHAR(20) NOT NULL, | ||
DOB DATE, | ||
ADDRESS_ID INT DEFAULT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS CONFIGURATION ( | ||
`KEY` VARCHAR(20) NOT NULL, | ||
`VALUE` VARCHAR(20) NOT NULL, | ||
PRIMARY KEY (`KEY`) | ||
); | ||
CREATE TABLE IF NOT EXISTS PRODUCT ( | ||
`ID` INT NOT NULL AUTO_INCREMENT, | ||
`NAME` VARCHAR(20) NOT NULL, | ||
PRIMARY KEY (`ID`) | ||
); | ||
CREATE TABLE IF NOT EXISTS SALE ( | ||
`PRODUCT_ID` INT NOT NULL, | ||
`PERSON_ID` INT NOT NULL, | ||
`SALE_DATE` DATETIME, | ||
PRIMARY KEY (`PRODUCT_ID`,`PERSON_ID`) | ||
); | ||
CREATE TABLE IF NOT EXISTS CELL4D ( | ||
`X` INT NOT NULL, | ||
`Y` INT NOT NULL, | ||
`Z` INT NOT NULL, | ||
`T` INT NOT NULL, | ||
`OCCUPIED` BOOLEAN, | ||
PRIMARY KEY (`X`, `Y`, `Z`, `T`) | ||
); | ||
**/ |
70 changes: 70 additions & 0 deletions
70
quill-cassandra-macro/src/test/scala/pl/jozwik/quillgeneric/cassandra/CassandraTest.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,70 @@ | ||
package pl.jozwik.quillgeneric.cassandra | ||
|
||
import com.datastax.driver.core.{ Cluster, Session } | ||
import com.datastax.driver.extras.codecs.jdk8.LocalDateTimeCodec | ||
import io.getquill.{ CassandraSyncContext, SnakeCase } | ||
import monix.execution.Scheduler | ||
import org.cassandraunit.CQLDataLoader | ||
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet | ||
import org.cassandraunit.utils.EmbeddedCassandraServerHelper | ||
import org.scalatest.BeforeAndAfterAll | ||
import pl.jozwik.quillgeneric.AbstractSpec | ||
import pl.jozwik.quillgeneric.cassandra.model.{ Address, AddressId } | ||
import pl.jozwik.quillgeneric.quillmacro.DateQuotes | ||
|
||
class CassandraTest extends AbstractSpec with BeforeAndAfterAll { | ||
protected implicit val scheduler: Scheduler = Scheduler.Implicits.global | ||
sys.props.put("quill.binds.log", true.toString) | ||
protected lazy val cluster: Cluster = { | ||
//EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE | ||
EmbeddedCassandraServerHelper.startEmbeddedCassandra() | ||
EmbeddedCassandraServerHelper.getCluster | ||
} | ||
protected lazy val session: Session = cluster.connect() | ||
|
||
protected val keySpace = "demo" | ||
|
||
lazy val syncCtx = new CassandraSyncContext(SnakeCase, "cassandra") with DateQuotes | ||
|
||
override def beforeAll(): Unit = { | ||
cluster.getConfiguration.getCodecRegistry.register(LocalDateTimeCodec.instance) | ||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra() | ||
val dataLoader = new CQLDataLoader(session) | ||
dataLoader.load(new ClassPathCQLDataSet("scripts/create.cql", keySpace)) | ||
} | ||
|
||
override protected def afterAll(): Unit = { | ||
super.afterAll() | ||
session.close() | ||
cluster.close() | ||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra() | ||
} | ||
|
||
"really simple transformation" should { | ||
|
||
"run sync" in { | ||
val id = AddressId.random | ||
val address = Address(id, "country", "city") | ||
import syncCtx._ | ||
val schema = syncCtx.dynamicQuerySchema[Address]("Address") | ||
syncCtx | ||
.run { | ||
schema.insertValue(address) | ||
} | ||
syncCtx | ||
.run { | ||
schema.insertValue(address) | ||
} | ||
val v = syncCtx | ||
.run( | ||
schema.filter(_.id == lift(id)) | ||
) | ||
logger.debug(s"$v") | ||
syncCtx | ||
.run( | ||
schema.filter(_.id == lift(id)).delete | ||
) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.