diff options
author | norrislee <norrislee18@hotmail.com> | 2014-07-30 13:31:20 -0700 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2014-08-11 21:33:43 -0700 |
commit | 687b9b0b6e8d30fcf2a1e4fc8f34ddc6728b1f69 (patch) | |
tree | cefe04b6b799b3a75ef4f3e0dfbed97782735b7e /contrib/native/client/src | |
parent | 90cd1949274aad87626083b835fc966b7f422777 (diff) |
DRILL-1226: C++ Client Decimal ignores leading zeros for decimal 9 and 18
Diffstat (limited to 'contrib/native/client/src')
-rw-r--r-- | contrib/native/client/src/include/drill/recordBatch.hpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp index d4735a99d..e9298bf17 100644 --- a/contrib/native/client/src/include/drill/recordBatch.hpp +++ b/contrib/native/client/src/include/drill/recordBatch.hpp @@ -350,7 +350,18 @@ template<typename VALUE_TYPE> void getValueAt(size_t index, char* buf, size_t nChars) const { VALUE_TYPE value = m_pBuffer->readAt<VALUE_TYPE>(index * sizeof(VALUE_TYPE)); - const std::string& str = boost::lexical_cast<std::string>(value); + std::string str = boost::lexical_cast<std::string>(value); + if (str[0] == '-') { + str = str.substr(1); + while (str.length() < m_scale) { + str = "0" + str; + } + str = "-" + str; + } else { + while (str.length() < m_scale) { + str = "0" + str; + } + } if (m_scale == 0) { strncpy(buf, str.c_str(), nChars); } else { |