Skip to content

Commit

Permalink
Action sbt scalafmtAll
Browse files Browse the repository at this point in the history
  • Loading branch information
takapi327 committed Jan 3, 2025
1 parent 6896a5b commit 74bd5a5
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ class TableQueryTest extends AnyFlatSpec:
it should "The delete query statement generated from Table is equal to the specified query statement." in {
assert(query.delete.statement === "DELETE FROM test")
assert(query.delete.where(_.p1 === 1L).statement === "DELETE FROM test WHERE test.p1 = ?")
assert(query.delete.whereOpt(Some(1L))((test, value) => test.p1 === value).statement === "DELETE FROM test WHERE test.p1 = ?")
assert(
query.delete
.whereOpt(Some(1L))((test, value) => test.p1 === value)
.statement === "DELETE FROM test WHERE test.p1 = ?"
)
assert(query.delete.whereOpt[Long](None)((test, value) => test.p1 === value).statement === "DELETE FROM test")
assert(query.delete.limit(1).statement === "DELETE FROM test LIMIT ?")
assert(query.delete.where(_.p1 === 1L).limit(1).statement === "DELETE FROM test WHERE test.p1 = ? LIMIT ?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ class TableQueryTest extends AnyFlatSpec:
it should "The delete query statement generated from Table is equal to the specified query statement." in {
assert(query.delete.statement === "DELETE FROM test")
assert(query.delete.where(_.p1 === 1L).statement === "DELETE FROM test WHERE test.p1 = ?")
assert(query.delete.whereOpt(Some(1L))((test, value) => test.p1 === value).statement === "DELETE FROM test WHERE test.p1 = ?")
assert(
query.delete
.whereOpt(Some(1L))((test, value) => test.p1 === value)
.statement === "DELETE FROM test WHERE test.p1 = ?"
)
assert(query.delete.whereOpt[Long](None)((test, value) => test.p1 === value).statement === "DELETE FROM test")
assert(query.delete.limit(1).statement === "DELETE FROM test LIMIT ?")
assert(query.delete.where(_.p1 === 1L).limit(1).statement === "DELETE FROM test WHERE test.p1 = ? LIMIT ?")
Expand Down
13 changes: 7 additions & 6 deletions module/ldbc-statement/src/main/scala/ldbc/statement/Delete.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ case class Delete[A](
statement = statement ++ s" WHERE ${ expression.statement }",
params = params ++ expression.parameter
)
case None => Where.C(
table,
statement,
params,
isFirst = true
)
case None =>
Where.C(
table,
statement,
params,
isFirst = true
)
18 changes: 9 additions & 9 deletions module/ldbc-statement/src/main/scala/ldbc/statement/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ case class Select[A, B](
case Some(value) =>
val expression = func(table, value)
Where.Q[A, B](
table = table,
columns = columns,
statement = statement ++ s" WHERE ${expression.statement}",
params = params ++ expression.parameter
table = table,
columns = columns,
statement = statement ++ s" WHERE ${ expression.statement }",
params = params ++ expression.parameter
)
case None =>
case None =>
Where.Q[A, B](
table = table,
columns = columns,
table = table,
columns = columns,
statement = statement,
params = params,
isFirst = true
params = params,
isFirst = true
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ object Update:
statement = statement ++ s" WHERE ${ expression.statement }",
params = params ++ expression.parameter
)
case None =>
case None =>
Where.C[A](
table = table,
table = table,
statement = statement,
params = params,
isFirst = true
params = params,
isFirst = true
)
28 changes: 22 additions & 6 deletions module/ldbc-statement/src/main/scala/ldbc/statement/Where.scala
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object Where:
columns: Column[B],
statement: String,
params: List[Parameter.Dynamic],
isFirst: Boolean = false
isFirst: Boolean = false
) extends Where[A],
Query[A, B],
OrderBy.Provider[A, B],
Expand All @@ -244,8 +244,16 @@ object Where:

override private[ldbc] def union(label: String, expression: Expression): Q[A, B] =
if isFirst then
this.copy(statement = statement ++ s" WHERE ${ expression.statement }", params = params ++ expression.parameter, isFirst = false)
else this.copy(statement = statement ++ s" $label ${ expression.statement }", params = params ++ expression.parameter)
this.copy(
statement = statement ++ s" WHERE ${ expression.statement }",
params = params ++ expression.parameter,
isFirst = false
)
else
this.copy(
statement = statement ++ s" $label ${ expression.statement }",
params = params ++ expression.parameter
)

/**
* A method for setting the GROUP BY condition in a SELECT statement.
Expand Down Expand Up @@ -283,7 +291,7 @@ object Where:
table: A,
statement: String,
params: List[Parameter.Dynamic],
isFirst: Boolean = false
isFirst: Boolean = false
) extends Where[A],
Command,
Limit.CommandProvider:
Expand All @@ -296,5 +304,13 @@ object Where:

override private[ldbc] def union(label: String, expression: Expression): C[A] =
if isFirst then
this.copy(statement = statement ++ s" WHERE ${ expression.statement }", params = params ++ expression.parameter, isFirst = false)
else this.copy(statement = statement ++ s" $label ${ expression.statement }", params = params ++ expression.parameter)
this.copy(
statement = statement ++ s" WHERE ${ expression.statement }",
params = params ++ expression.parameter,
isFirst = false
)
else
this.copy(
statement = statement ++ s" $label ${ expression.statement }",
params = params ++ expression.parameter
)

0 comments on commit 74bd5a5

Please sign in to comment.