diff --git a/docs/ref/transforms.rst b/docs/ref/transforms.rst index b29fa15..f90f5df 100644 --- a/docs/ref/transforms.rst +++ b/docs/ref/transforms.rst @@ -84,6 +84,14 @@ The provided transformation functions are: In: 100.0d0 Out: "100.0" + - *hex-to-dec* + + Converts a string containing an hexadecimal representation of a number + into its decimal representation:: + + In: "deadbeef" + Out: "3735928559" + - *set-to-enum-array* Converts a string representing a MySQL SET into a PostgreSQL Array of diff --git a/src/utils/transforms.lisp b/src/utils/transforms.lisp index 4f6e1ed..497b154 100644 --- a/src/utils/transforms.lisp +++ b/src/utils/transforms.lisp @@ -374,7 +374,8 @@ (null nil) (string (base64:base64-string-to-string string)))) -(defun hex-to-dec (string) - (etypecase hex +(defun hex-to-dec (hex-string) + (etypecase hex-string (null nil) - (string (write-to-string (parse-integer hex :radix 16))))) + (integer hex-string) + (string (write-to-string (parse-integer hex-string :radix 16)))))