clj-r2dbc.impl.coerce

Internal type-coercion utilities shared across clj-r2dbc namespaces.

Provides:
  byte-array-class      - the Class object for the Java byte[] type.
  parameter-type->class - resolves an R2DBC Type to a Java Class.
  java-array->clj       - converts a Java array value to a persistent vector.
  coerce-row-arrays     - applies java-array->clj to every value in a row map.
  coerce-numeric-row    - coerces Double/Float values in a row map to BigDecimal.

This namespace is an implementation detail; do not use from application code.

byte-array-class

The Class object for the Java byte array type ("[B").

coerce-numeric-row

(coerce-numeric-row row)
Coerce Double and Float values in a row map to BigDecimal.

Converts via (bigdec (str v)) to preserve the string representation of the
floating-point value. All other values are unchanged.

Args:
  row - map of column keyword to column value.

coerce-row-arrays

(coerce-row-arrays row)
Apply java-array->clj to every value in a row map.

Args:
  row - map of column keyword to column value.

Returns a new map with the same keys; byte[] column values are preserved as-is.

java-array->clj

(java-array->clj v)
Convert a Java array value to a persistent Clojure vector.

byte[] values are returned as-is (preserving binary data). nil and any other
non-array value are returned unchanged.

Args:
  v - any value.

parameter-type->class

(parameter-type->class t)
Resolve an R2DBC Type descriptor to a Java Class for use with Statement.bindNull.

Returns the Class as-is when t is already a Class, the result of
Type.getJavaType() when t is an R2DBC Type (falling back to Object when
getJavaType() returns nil), and Object for nil or any other type.

Args:
  t - Class, R2DBC Type, or nil.