Skip to content
Snippets Groups Projects
Commit 872140cb authored by Steven Murray's avatar Steven Murray
Browse files

Moved c_maxSqlLenInExceptions to rdbms/Constants.hpp

parent 7dfc1a75
No related branches found
No related tags found
No related merge requests found
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <string>
namespace cta {
namespace rdbms {
/**
* The maximum length an SQL statement can have in exception error message.
*/
const uint32_t MAX_SQL_LEN_IN_EXCEPTIONS = 80;
} // namespace rdbms
} // namespace cta
......@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rdbms/Constants.hpp"
#include "rdbms/wrapper/Stmt.hpp"
namespace cta {
......@@ -62,13 +63,13 @@ uint32_t Stmt::getParamIdx(const std::string &paramName) const {
// getSqlForException
//------------------------------------------------------------------------------
std::string Stmt::getSqlForException() const {
if(m_sql.length() <= c_maxSqlLenInExceptions) {
if(m_sql.length() <= MAX_SQL_LEN_IN_EXCEPTIONS) {
return m_sql;
} else {
if(c_maxSqlLenInExceptions >= 3) {
return m_sql.substr(0, c_maxSqlLenInExceptions - 3) + "...";
if(MAX_SQL_LEN_IN_EXCEPTIONS >= 3) {
return m_sql.substr(0, MAX_SQL_LEN_IN_EXCEPTIONS - 3) + "...";
} else {
return std::string("..."). substr(0, c_maxSqlLenInExceptions);
return std::string("...").substr(0, MAX_SQL_LEN_IN_EXCEPTIONS);
}
}
}
......
......@@ -190,13 +190,6 @@ public:
*/
std::string getSqlForException() const;
protected:
/**
* The maximum length an SQL statement can have in exception error message.
*/
const uint32_t c_maxSqlLenInExceptions = 80;
private:
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment