From cb9e01f4d96047a0d63b6891a4c60296fd922577 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 27 Mar 2018 14:55:31 +0200 Subject: [PATCH] Code review for previous commit. See #771. --- docs/ref/transforms.rst | 8 ++++++++ src/utils/transforms.lisp | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) 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)))))