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 30, 2024
1 parent 7a8674e commit e9846fe
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 @@ -14,6 +14,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 @@ -39,7 +41,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 e9846fe

Please sign in to comment.