diff --git a/client/src/main/scala/raw/client/api/ProgramDescription.scala b/client/src/main/scala/raw/client/api/ProgramDescription.scala index c2a3cc259..b94914eb9 100644 --- a/client/src/main/scala/raw/client/api/ProgramDescription.scala +++ b/client/src/main/scala/raw/client/api/ProgramDescription.scala @@ -14,7 +14,7 @@ package raw.client.api final case class ProgramDescription( decls: Map[String, List[DeclDescription]], - maybeType: Option[RawType], + maybeRunnable: Option[DeclDescription], comment: Option[String] ) diff --git a/snapi-client/src/main/scala/raw/client/rql2/truffle/Rql2TruffleCompilerService.scala b/snapi-client/src/main/scala/raw/client/rql2/truffle/Rql2TruffleCompilerService.scala index a3afbeb9e..c3300a601 100644 --- a/snapi-client/src/main/scala/raw/client/rql2/truffle/Rql2TruffleCompilerService.scala +++ b/snapi-client/src/main/scala/raw/client/rql2/truffle/Rql2TruffleCompilerService.scala @@ -182,7 +182,7 @@ class Rql2TruffleCompilerService(engineDefinition: (Engine, Boolean), maybeClass formattedDecls, maybeType.map { t => rql2TypeToRawType(t) match { - case Some(rawType) => rawType + case Some(rawType) => DeclDescription(None, rawType, None) case None => return GetProgramDescriptionFailure( List(ErrorMessage(UnsupportedType.message, List.empty, UnsupportedType.code)) ) diff --git a/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala b/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala index b57565fc9..18d22b4c1 100644 --- a/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala +++ b/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala @@ -93,8 +93,8 @@ class SqlCompilerService(maybeClassLoader: Option[ClassLoader] = None)(implicit // Regardless if there are parameters, we declare a main function with the output type. // This permits the publish endpoints from the UI (https://raw-labs.atlassian.net/browse/RD-10359) val ok = ProgramDescription( - Map("main" -> List(DeclDescription(Some(ps.toVector), iterableType, None))), - None, + Map.empty, + Some(DeclDescription(Some(ps.toVector), iterableType, None)), None ) GetProgramDescriptionSuccess(ok) diff --git a/sql-client/src/test/scala/raw/client/sql/TestNamedParametersStatement.scala b/sql-client/src/test/scala/raw/client/sql/TestNamedParametersStatement.scala index 8080abb4f..dea1dcb08 100644 --- a/sql-client/src/test/scala/raw/client/sql/TestNamedParametersStatement.scala +++ b/sql-client/src/test/scala/raw/client/sql/TestNamedParametersStatement.scala @@ -47,22 +47,6 @@ class TestNamedParametersStatement extends RawTestSuite with SettingsTestContext super.afterAll() } - test("bug") { _ => - assume(password != "") - - val code = """-- @type aeroport_id smallint - |SELECT :city::json FROM example.airports WHERE airport_id = :aeroport_id""".stripMargin - - val statement = new NamedParametersPreparedStatement(con, parse(code)) - val metadata = statement.queryMetadata - assert(metadata.isLeft) - statement.setString("v1", "Hello!") - val rs = statement.executeQuery() - - rs.next() - assert(rs.getString("arg") == "Hello!") - } - test("single parameter") { _ => assume(password != "") diff --git a/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala b/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala index edb0c8bae..81d25bd94 100644 --- a/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala +++ b/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala @@ -364,8 +364,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, environment) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == airportType ) @@ -409,8 +409,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, environment) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == airportType ) @@ -448,8 +448,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, environment) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == airportType ) @@ -598,8 +598,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, withCity) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, withCity) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == RawIterableType( RawRecordType(Vector(RawAttrType("count", RawLongType(true, false))), false, false), @@ -644,8 +644,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, withCity) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, withCity) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == RawIterableType( RawRecordType(Vector(RawAttrType("count", RawLongType(true, false))), false, false), @@ -674,8 +674,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte val v = compilerService.validate(t.q, environment) assert(v.messages.isEmpty) val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment) - assert(description.maybeType.isEmpty) - val List(main) = description.decls("main") + assert(description.decls.isEmpty) + val Some(main) = description.maybeRunnable assert( main.outType == RawIterableType( RawRecordType(