Skip to content

Commit

Permalink
finos#1296 add todos, stuff that needs to be changed before final PR
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidzm13 committed Apr 26, 2024
1 parent 6e8ebf2 commit 6b154e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ case class EqIgniteSqlFilterClause(columnName: String, value: String) extends Ig
override def toSql(schemaMapper: SchemaMapper): String =
SqlFilterColumnValueParser(schemaMapper).parseColumnValue(columnName, value) match {
case Right(ParsedResult(f, parsedValue)) => f.dataType match {
case CharDataType | StringDataType => eqSql(f.name, quotedString(parsedValue))
case CharDataType | StringDataType => eqSql(f.name, quotedString(parsedValue)) // @todo CharDataType doesn't cover java.lang.Character
case _ => eqSql(f.name, parsedValue)
}
case Left(errMsg) => logErrorAndReturnEmptySql(errMsg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ trait SchemaMapper {
def externalSchemaField(columnName: String): Option[SchemaField]
def toMappedExternalFieldType(columnName: String, columnValue: Any): Option[Any]
def toMappedInternalColumnType(extFieldName: String, extFieldValue: Any): Option[Any]

// @todo to be moved out of this class, as this is not related to mapping between external and internal fields, only optional stuff needed for SQL filters
def convertExternalValueToString(extFieldName: String, extFieldValue: Any): Option[String]
def toInternalRowMap(externalValues: List[_]): Map[String, Any]
def toInternalRowMap(externalDto: Product): Map[String, Any]
Expand All @@ -43,7 +45,7 @@ private class SchemaMapperImpl(private val externalSchema: ExternalEntitySchema,
private def toInternalRowMap(externalValues: Array[_]): Map[String, Any] = {
externalFieldByColumnName.map({ case (columnName, extField) =>
val extFieldValue = externalValues(extField.index)
// remove this get and make this return Optional (need to guard against conversion error if a user sends in a value not matching the schema type)
// @todo remove this get and make this return Optional (need to guard against conversion error if a user sends in a value not matching the schema type)
val columnValue = toMappedInternalColumnType(extField.name, extFieldValue).get
(columnName, columnValue)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private case class TypeConverterContainerImpl(

override def convert[From, To](value: From, fromClass: Class[From], toClass: Class[To]): Option[To] = {
if (TypeUtils.areTypesEqual(fromClass, toClass)) {
return Some(value.asInstanceOf[To])
return Try(value.asInstanceOf[To]).toOption
}
typeConverter[From, To](fromClass, toClass).flatMap(tc => Try(tc.convert(value)).toOption)
}
Expand Down

0 comments on commit 6b154e8

Please sign in to comment.