Commit 5934c6e5 authored by msobczak's avatar msobczak

Added handling of case for column names in dynamic row binding.

parent 5474cb40
......@@ -16,7 +16,22 @@ using namespace details;
void row::add_properties(column_properties const &cp)
{
columns_.push_back(cp);
index_[cp.get_name()] = columns_.size() - 1;
std::string columnName;
std::string const & originalName = cp.get_name();
if (uppercaseColumnNames_)
{
for (size_t i = 0; i != originalName.size(); ++i)
{
columnName.push_back(std::toupper(originalName[i]));
}
}
else
{
columnName = originalName;
}
index_[columnName] = columns_.size() - 1;
}
std::size_t row::size() const
......
......@@ -40,8 +40,9 @@ private:
class SOCI_DECL row
{
public:
//TODO! friend class column_properites
// private
void uppercase_column_names(bool forceToUpper)
{ uppercaseColumnNames_ = forceToUpper; }
void add_properties(column_properties const &cp);
std::size_t size() const;
......@@ -125,14 +126,14 @@ public:
{
currentPos_ = 0;
}
row() : currentPos_(0) {}
row() : uppercaseColumnNames_(false), currentPos_(0) {}
~row();
private:
// copy not supported
row(row const &);
row operator=(row const &);
void operator=(row const &);
std::size_t find_column(std::string const &name) const;
......@@ -141,6 +142,8 @@ private:
std::vector<eIndicator*> indicators_;
std::map<std::string, std::size_t> index_;
bool uppercaseColumnNames_;
mutable std::size_t currentPos_;
};
......
......@@ -48,20 +48,22 @@ void ensureConnected(session_backend *backEnd)
session::session()
: once(this), prepare(this), logStream_(NULL),
lastFactory_(NULL), backEnd_(NULL)
lastFactory_(NULL), uppercaseColumnNames_(false), backEnd_(NULL)
{
}
session::session(backend_factory const & factory,
std::string const & connectString)
: once(this), prepare(this), logStream_(NULL),
lastFactory_(&factory), lastConnectString_(connectString)
lastFactory_(&factory), lastConnectString_(connectString),
uppercaseColumnNames_(false)
{
backEnd_ = factory.make_session(connectString);
}
session::session(std::string const & connectString)
: once(this), prepare(this), logStream_(NULL)
: once(this), prepare(this), logStream_(NULL),
uppercaseColumnNames_(false)
{
std::string backendName;
std::string connectionParameters;
......
......@@ -67,6 +67,12 @@ public:
void set_got_data(bool gotData) { gotData_ = gotData; }
bool got_data() const { return gotData_; }
void uppercase_column_names(bool forceToUpper)
{ uppercaseColumnNames_ = forceToUpper; }
bool get_uppercase_column_names() const
{ return uppercaseColumnNames_; }
// for diagnostics and advanced users
// (downcast it to expected back-end session class)
details::session_backend * get_backend() { return backEnd_; }
......@@ -87,6 +93,8 @@ private:
backend_factory const *lastFactory_;
std::string lastConnectString_;
bool uppercaseColumnNames_;
details::session_backend *backEnd_;
bool gotData_;
......
......@@ -638,6 +638,7 @@ void statement_impl::set_row(row *r)
}
row_ = r;
row_->uppercase_column_names(session_.get_uppercase_column_names());
}
std::string statement_impl::rewrite_for_procedure_call(std::string const &query)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment