Skip to content

Commit

Permalink
Action sbt scalafmtAll
Browse files Browse the repository at this point in the history
  • Loading branch information
takapi327 committed Oct 30, 2023
1 parent 8a2e502 commit 3d906d7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
5 changes: 3 additions & 2 deletions core/src/main/scala/ldbc/core/Alias.scala
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ private[ldbc] trait Alias:
name: String,
column: Column[T],
reference: Reference[Column[T] *: EmptyTuple]
): ForeignKey[Column[T] *: EmptyTuple] = ForeignKey[Column[T] *: EmptyTuple](Some(name), column *: EmptyTuple, reference)
): ForeignKey[Column[T] *: EmptyTuple] =
ForeignKey[Column[T] *: EmptyTuple](Some(name), column *: EmptyTuple, reference)

def FOREIGN_KEY[T <: Tuple](
columns: T,
Expand Down Expand Up @@ -196,7 +197,7 @@ private[ldbc] trait Alias:
): Reference[Column[T] *: EmptyTuple] = Reference[Column[T] *: EmptyTuple](table, column *: EmptyTuple, None, None)

def REFERENCE[T <: Tuple](
table: Table[?],
table: Table[?],
columns: T
)(using Tuples.IsColumn[T] =:= true): Reference[T] =
Reference[T](table, columns, None, None)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/ldbc/core/Key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ private[ldbc] case class ForeignKey[T <: Tuple](
indexName: Option[String],
columns: T,
reference: Reference[T]
)(using Tuples.IsColumn[T] =:= true) extends Key:
)(using Tuples.IsColumn[T] =:= true)
extends Key:

override val label: String = "FOREIGN KEY"

Expand Down
9 changes: 4 additions & 5 deletions core/src/main/scala/ldbc/core/Table.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ private[ldbc] trait Table[P <: Product] extends Dynamic:

object Table extends Dynamic:

extension[P <: Product](table: Table[P])

extension [P <: Product](table: Table[P])
/** Methods for statically accessing column information held by a Table.
*/
*/
transparent inline def selectDynamic[Tag <: Singleton](
tag: Tag
)(using
mirror: Mirror.ProductOf[P],
index: ValueOf[Tuples.IndexOf[mirror.MirroredElemLabels, Tag]]
index: ValueOf[Tuples.IndexOf[mirror.MirroredElemLabels, Tag]]
): Column[Tuple.Elem[mirror.MirroredElemTypes, Tuples.IndexOf[mirror.MirroredElemLabels, Tag]]] =
val column = table.columns
.productElement(index.value)
Expand Down Expand Up @@ -157,6 +156,6 @@ object Table extends Dynamic:
private def fromTupleMap[P <: Product](using
mirror: Mirror.ProductOf[P]
)(
name: String,
name: String,
columns: Tuple.Map[mirror.MirroredElemTypes, Column]
): Table[P] = Impl[P, mirror.MirroredElemTypes](name, columns, Seq.empty, Seq.empty, None)
11 changes: 5 additions & 6 deletions core/src/main/scala/ldbc/core/interpreter/Tuples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ object Tuples:
case E *: _ => 0
case _ *: es => S[IndexOf[es, E]]

/**
* Type to verify that a tuple of a given type consists only of the type wrapped in Column.
*/
/** Type to verify that a tuple of a given type consists only of the type wrapped in Column.
*/
type IsColumn[T <: Tuple] <: Boolean = T match
case EmptyTuple => false
case Column[t] => true
case EmptyTuple => false
case Column[t] => true
case Column[t] *: EmptyTuple => true
case Column[t] *: ts => IsColumn[ts]
case Column[t] *: ts => IsColumn[ts]
9 changes: 3 additions & 6 deletions core/src/test/scala/ldbc/core/TableTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class TableTest extends AnyFlatSpec:
}

it should "Foreign key constraints can be set between the same type without any problem." in {
assertCompiles(
"""
assertCompiles("""
import ldbc.core.*
case class Test(id: Long, subId: Long)
Expand All @@ -88,8 +87,7 @@ class TableTest extends AnyFlatSpec:
}

it should "Setting foreign key constraints between different types results in a compile error." in {
assertDoesNotCompile(
"""
assertDoesNotCompile("""
import ldbc.core.*
case class Test(id: Long, subId: Long)
Expand All @@ -111,8 +109,7 @@ class TableTest extends AnyFlatSpec:
}

it should "" in {
assertCompiles(
"""
assertCompiles("""
import ldbc.core.*
case class Test(id: Long, subId: Long, subCategory: Short)
Expand Down

0 comments on commit 3d906d7

Please sign in to comment.