Skip to content

Commit

Permalink
run prePR
Browse files Browse the repository at this point in the history
  • Loading branch information
CJSmith-0141 committed Jul 30, 2023
1 parent 17d883f commit 5a65d39
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 11 deletions.
20 changes: 17 additions & 3 deletions core/src/main/scala/net/tazato/absurd/ql/statements/Create.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.statements

import net.tazato.absurd.ql.traits.*
Expand All @@ -20,8 +36,6 @@ object Create extends Render[Create]:
case PROJECTIONS(x) => s"RETURN ${x.mkString(", ")}"
end ReturnMode



def renderFieldsWithValues(fwv: Seq[(Field, ValueLike)]): String =
fwv.map(x => s"${x._1.render} = ${x._2.render}").mkString(", ")

Expand All @@ -43,7 +57,7 @@ object Create extends Render[Create]:
Seq[Option[String]](
"CREATE".some,
LazyRender.renderSeqOption(x.createTargets),
x.content.map( y => s"CONTENT $y"),
x.content.map(y => s"CONTENT $y"),
if (x.fieldsWithValues.isEmpty) None
else Some("SET " ++ renderFieldsWithValues(x.fieldsWithValues)),
x.returnMode.map(_.render),
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala/net/tazato/absurd/ql/types/Alias.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

import net.tazato.absurd.ql.traits.LazyRender
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala/net/tazato/absurd/ql/types/Cond.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

import net.tazato.absurd.ql.traits.LazyRender
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala/net/tazato/absurd/ql/types/Duration.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

case class Duration(dur: String)
16 changes: 16 additions & 0 deletions core/src/main/scala/net/tazato/absurd/ql/types/Field.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

import net.tazato.absurd.ql.traits.LazyRender
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala/net/tazato/absurd/ql/types/Target.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

import net.tazato.absurd.ql.traits.LazyRender
Expand Down
20 changes: 18 additions & 2 deletions core/src/main/scala/net/tazato/absurd/ql/types/ValueLike.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.types

import net.tazato.absurd.ql.traits.LazyRender

enum ValueLike(val value: String) extends LazyRender:
case Stringish(x: String) extends ValueLike(x)
case Jsonish(x: String) extends ValueLike(x)
case Jsonish(x: String) extends ValueLike(x)
override lazy val render: String =
this match
case Stringish(x) => s"'$x'"
case Jsonish(x) => s"$x"
case Jsonish(x) => s"$x"
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Connor James Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.tazato.absurd.ql.statements

import net.tazato.absurd.ql.types.*
Expand All @@ -22,20 +38,21 @@ object CreateSuite extends FunSuite {
}

test("Create Statement: render works, content example") {
val expected = """CREATE person CONTENT {
val expected = """CREATE person CONTENT {
| name: 'Tobie',
| company: 'SurrealDB',
| skills: ['Rust', 'Go', 'JavaScript'],
|};""".stripMargin
val rendered = Create.CREATE(
createTargets = Seq(Target("person")),
val rendered = Create
.CREATE(
createTargets = Seq(Target("person")),
content = Some("""{
| name: 'Tobie',
| company: 'SurrealDB',
| skills: ['Rust', 'Go', 'JavaScript'],
|}""".stripMargin
)
).render
|}""".stripMargin)
)
.render

expect.same(expected, rendered)
}
Expand Down

0 comments on commit 5a65d39

Please sign in to comment.