From 3cfe5186a4959452ba717ddc5b95cffd910f6c02 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 4 Jul 2012 13:23:48 +0000 Subject: [PATCH] Sql: Fixed issue with lowercase SqlId in operator[] git-svn-id: svn://ultimatepp.org/upp/trunk@5113 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Sql/Session.cpp | 5 ++++- uppsrc/Sql/Sql.cpp | 22 ++++++++++++++-------- uppsrc/Sql/Sqls.h | 5 ++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/uppsrc/Sql/Session.cpp b/uppsrc/Sql/Session.cpp index 540fb8c4a..662e67fc5 100644 --- a/uppsrc/Sql/Session.cpp +++ b/uppsrc/Sql/Session.cpp @@ -17,6 +17,7 @@ SqlSession::SqlSession() errorclass = Sql::ERROR_UNSPECIFIED; error_handler = NULL; throwonerror = false; + error_log = NULL; } SqlSession::~SqlSession() @@ -71,7 +72,9 @@ void SqlSession::SetError(String error, String stmt, int code, const char *sco errorclass = clss; String err; err << "ERROR " << error << "(" << code << "): " << stmt << '\n'; - if(GetTrace()) + if(error_log) + *error_log << err; + if(trace && trace != error_log) *GetTrace() << err; } diff --git a/uppsrc/Sql/Sql.cpp b/uppsrc/Sql/Sql.cpp index 985d17133..52618d9f5 100644 --- a/uppsrc/Sql/Sql.cpp +++ b/uppsrc/Sql/Sql.cpp @@ -310,11 +310,14 @@ void Sql::GetColumn(int i, Ref r) const { void Sql::GetColumn(SqlId colid, Ref r) const { String s = ~colid; - for(int i = 0; i < cn->info.GetCount(); i++) - if(cn->info[i].name == s) { - GetColumn(i, r); - return; - } + for(int j = 0; j < 2; j++) { + for(int i = 0; i < cn->info.GetCount(); i++) + if(cn->info[i].name == s) { + GetColumn(i, r); + return; + } + s = ToUpper(s); + } r.SetNull(); } @@ -326,9 +329,12 @@ Value Sql::operator[](int i) const { Value Sql::operator[](SqlId id) const { String s = ~id; - for(int i = 0; i < cn->info.GetCount(); i++) - if(cn->info[i].name == s) - return operator[](i); + for(int j = 0; j < 2; j++) { + for(int i = 0; i < cn->info.GetCount(); i++) + if(cn->info[i].name == s) + return operator[](i); + s = ToUpper(s); + } NEVER(); return Value(); } diff --git a/uppsrc/Sql/Sqls.h b/uppsrc/Sql/Sqls.h index 20673e723..ae664d800 100644 --- a/uppsrc/Sql/Sqls.h +++ b/uppsrc/Sql/Sqls.h @@ -300,7 +300,7 @@ protected: friend class Sql; - Stream *trace; + Stream *trace, *error_log; bool tracetime; int traceslow; int dialect; @@ -355,6 +355,9 @@ public: Stream *GetTrace() const { return trace; } void KillTrace() { trace = NULL; } + void LogErrors(Stream& s = VppLog()) { error_log = &s; } + void LogErrors(bool b) { error_log = b ? &VppLog() : NULL; } + void TraceTime(bool b = true) { tracetime = b; } bool IsTraceTime() const { return tracetime; }