Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeMapper.scala added support for Float data type #32

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scalasql/core/src/DialectTypeMappers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ trait DialectTypeMappers extends DialectConfig {
implicit def IntType: TypeMapper[Int]
implicit def LongType: TypeMapper[Long]

implicit def FloatType: TypeMapper[Float]
implicit def DoubleType: TypeMapper[Double]
implicit def BigDecimalType: TypeMapper[scala.math.BigDecimal]
implicit def BooleanType: TypeMapper[Boolean]
Expand Down
3 changes: 2 additions & 1 deletion scalasql/core/src/TypeMapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ object TypeMapper {
d.IntType
implicit def longFromDialectTypeMappers(implicit d: DialectTypeMappers): TypeMapper[Long] =
d.LongType

implicit def floatFromDialectTypeMappers(implicit d: DialectTypeMappers): TypeMapper[Float] =
d.FloatType
implicit def doubleFromDialectTypeMappers(implicit d: DialectTypeMappers): TypeMapper[Double] =
d.DoubleType
implicit def bigDecimalFromDialectTypeMappers(
Expand Down
7 changes: 7 additions & 0 deletions scalasql/src/dialects/Dialect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ trait Dialect extends DialectTypeMappers {
def put(r: PreparedStatement, idx: Int, v: Long) = r.setLong(idx, v)
}

implicit def FloatType: TypeMapper[Float] = new FloatType
class FloatType extends TypeMapper[Float] {
def jdbcType = JDBCType.FLOAT
def get(r: ResultSet, idx: Int) = r.getFloat(idx)
def put(r: PreparedStatement, idx: Int, v: Float) = r.setDouble(idx, v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmorales-iaa should this be setFloat, for symmetry with the getFloat above?

}

implicit def DoubleType: TypeMapper[Double] = new DoubleType
class DoubleType extends TypeMapper[Double] {
def jdbcType = JDBCType.DOUBLE
Expand Down
Loading