Skip to content

Commit 7874613

Browse files
committed
correct cassandra
1 parent 7dc87d2 commit 7874613

File tree

10 files changed

+31
-22
lines changed

10 files changed

+31
-22
lines changed

macro-quill/src/test/resources/scripts/create.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ CREATE TABLE IF NOT EXISTS ADDRESS
66
STREET VARCHAR(50) DEFAULT NULL,
77
BUILDING_NUMBER VARCHAR(10) DEFAULT NULL,
88
LOCAL_NUMBER VARCHAR(10) DEFAULT NULL,
9-
UPDATED DATETIME
9+
UPDATED DATETIME,
10+
CREATED DATE DEFAULT NULL
1011
);
1112

1213
CREATE TABLE IF NOT EXISTS PERSON
@@ -15,7 +16,8 @@ CREATE TABLE IF NOT EXISTS PERSON
1516
FIRST_NAME VARCHAR(50) NOT NULL,
1617
LAST_NAME VARCHAR(20) NOT NULL,
1718
BIRTH_DATE DATE,
18-
ADDRESS_ID INT DEFAULT NULL
19+
ADDRESS_ID INT DEFAULT NULL,
20+
CREATE_DATE_TIME DATETIME DEFAULT NULL
1921
);
2022

2123

@@ -25,7 +27,8 @@ CREATE TABLE IF NOT EXISTS PERSON2
2527
FIRST_NAME VARCHAR(50) NOT NULL,
2628
LAST_NAME VARCHAR(20) NOT NULL,
2729
BIRTH_DATE DATE,
28-
ADDRESS_ID INT DEFAULT NULL
30+
ADDRESS_ID INT DEFAULT NULL,
31+
CREATE_DATE_TIME DATETIME DEFAULT NULL
2932
);
3033

3134
CREATE TABLE IF NOT EXISTS PERSON3
@@ -34,7 +37,8 @@ CREATE TABLE IF NOT EXISTS PERSON3
3437
FIRST_NAME VARCHAR(50) NOT NULL,
3538
LAST_NAME VARCHAR(20) NOT NULL,
3639
DOB DATE,
37-
ADDRESS_ID INT DEFAULT NULL
40+
ADDRESS_ID INT DEFAULT NULL,
41+
CREATE_DATE_TIME DATETIME DEFAULT NULL
3842
);
3943

4044

@@ -48,13 +52,16 @@ CREATE TABLE IF NOT EXISTS CONFIGURATION (
4852
CREATE TABLE IF NOT EXISTS PRODUCT (
4953
`ID` INT NOT NULL AUTO_INCREMENT,
5054
`NAME` VARCHAR(20) NOT NULL,
55+
`CREATED` DATE,
5156
PRIMARY KEY (`ID`)
5257
);
5358

5459
CREATE TABLE IF NOT EXISTS SALE (
5560
`PRODUCT_ID` INT NOT NULL,
5661
`PERSON_ID` INT NOT NULL,
5762
`SALE_DATE` DATETIME,
63+
`SALE_DATE_TIME` DATETIME,
64+
`CREATE_DATE` DATE,
5865
PRIMARY KEY (`PRODUCT_ID`,`PERSON_ID`)
5966
);
6067

macro-quill/src/test/scala/pl/jozwik/quillgeneric/AbstractSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package pl.jozwik.quillgeneric
22

33
import java.time.temporal.ChronoUnit
4-
import java.time.{ Instant, LocalDate }
5-
4+
import java.time.{ Instant, LocalDate, LocalDateTime, ZoneOffset }
65
import com.typesafe.scalalogging.StrictLogging
76
import io.getquill.NamingStrategy
87
import org.scalatest.concurrent.{ AsyncTimeLimitedTests, TimeLimitedTests }
@@ -24,6 +23,7 @@ trait AbstractSpec extends AnyWordSpecLike with TimeLimitedTests with Spec with
2423

2524
protected val now: Instant = Instant.now().truncatedTo(ChronoUnit.SECONDS)
2625
protected val today: LocalDate = LocalDate.now
26+
protected val dateTime: LocalDateTime = LocalDateTime.ofInstant(now, ZoneOffset.UTC)
2727
protected val strategy: NamingStrategy = Strategy.namingStrategy
2828

2929
protected val (offset, limit) = (0, 100)

macro-quill/src/test/scala/pl/jozwik/quillgeneric/model/Person.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ final case class Person(
1515
lastName: String,
1616
birthDate: LocalDate,
1717
addressId: Option[AddressId] = Option(AddressId.empty),
18-
createDateTime: Option[LocalDateTime] = None
18+
createDateTime: Option[LocalDateTime] = Option(LocalDateTime.now)
1919
) extends WithId[PersonId]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package pl.jozwik.quillgeneric.model
22

3-
import java.time.{ Instant, LocalDateTime }
3+
import java.time.{ Instant, LocalDate, LocalDateTime }
44
import pl.jozwik.quillgeneric.quillmacro.{ CompositeKey2, WithId }
55

66
final case class SaleId(fk1: ProductId, fk2: PersonId) extends CompositeKey2[ProductId, PersonId] {
77
def productId: ProductId = fk1
88
def personId: PersonId = fk2
99
}
1010

11-
12-
final case class Sale(id: SaleId, saleDate: Instant, saleDateTime: LocalDateTime = LocalDateTime.now) extends WithId[SaleId]
11+
final case class Sale(id: SaleId, saleDate: Instant, saleDateTime: LocalDateTime, createDate: LocalDate) extends WithId[SaleId]

quill-cassandra-macro/src/test/resources/scripts/create.cql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ CREATE TABLE IF NOT EXISTS ADDRESS
66
STREET TEXT,
77
BUILDING_NUMBER TEXT,
88
LOCAL_NUMBER TEXT,
9-
UPDATED TIMESTAMP
9+
UPDATED TIMESTAMP,
10+
CREATED DATE
1011
);

quill-cassandra-macro/src/test/scala/pl/jozwik/quillgeneric/cassandra/AbstractCassandraSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait AbstractCassandraSpec extends AbstractSpec with BeforeAndAfterAll {
1313

1414
protected lazy val session = {
1515
EmbeddedCassandraServerHelper.startEmbeddedCassandra()
16-
EmbeddedCassandraServerHelper.getSession()
16+
EmbeddedCassandraServerHelper.getSession
1717
}
1818

1919
protected val keySpace = "demo"

quill-cassandra-macro/src/test/scala/pl/jozwik/quillgeneric/cassandra/model/Address.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package pl.jozwik.quillgeneric.cassandra.model
22

3-
import java.util.{ Date, UUID }
4-
53
import pl.jozwik.quillgeneric.quillmacro.WithId
64

5+
import java.time.LocalDate
6+
import java.util.{ Date, UUID }
7+
78
object AddressId {
89
val random: AddressId = AddressId(UUID.randomUUID())
910
}
@@ -17,5 +18,6 @@ final case class Address(
1718
street: Option[String] = None,
1819
buildingNumber: Option[String] = None,
1920
updated: Option[Date] = None,
20-
localNumber: Option[String] = None
21+
localNumber: Option[String] = None,
22+
created: Option[LocalDate] = None
2123
) extends WithId[AddressId]

quill-cassandra-monix-macro/src/test/resources/scripts/create.cql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ CREATE TABLE IF NOT EXISTS ADDRESS
66
STREET TEXT,
77
BUILDING_NUMBER TEXT,
88
LOCAL_NUMBER TEXT,
9-
UPDATED TIMESTAMP
9+
UPDATED TIMESTAMP,
10+
CREATED DATE
1011
);

quill-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/sync/jdbc/SaleRepositorySuite.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait SaleRepositorySuite extends AbstractJdbcSpec {
2121
val productWithoutId = Product(ProductId.empty, "productName")
2222
val product = productRepository.createAndRead(productWithoutId).success.value
2323
val saleId = SaleId(product.id, person.id)
24-
val sale = Sale(saleId, now)
24+
val sale = Sale(saleId, now, dateTime, today)
2525
repository.createAndRead(sale) shouldBe Symbol("success")
2626

2727
repository.createOrUpdateAndRead(sale) shouldBe Symbol("success")
@@ -35,10 +35,9 @@ trait SaleRepositorySuite extends AbstractJdbcSpec {
3535
actualSeq shouldBe Seq(sale)
3636
}
3737
}
38-
.recoverWith {
39-
case th =>
40-
logger.error("", th)
41-
Failure(th)
38+
.recoverWith { case th =>
39+
logger.error("", th)
40+
Failure(th)
4241
}
4342
.success
4443
.value

version.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ThisBuild / version := "1.1.1"
1+
ThisBuild / version := "1.1.1-SNAPSHOT"

0 commit comments

Comments
 (0)