From c94daa95e01e9b8d4c941e344268b8d7bdc4b688 Mon Sep 17 00:00:00 2001 From: randomdan Date: Sun, 13 Feb 2011 21:02:18 +0000 Subject: Fixed handling of ?s in string literals --- libpqpp/command.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libpqpp') diff --git a/libpqpp/command.cpp b/libpqpp/command.cpp index 7617bd1..a7dd1fd 100644 --- a/libpqpp/command.cpp +++ b/libpqpp/command.cpp @@ -33,11 +33,16 @@ PQ::Command::prepare() const psql.reserve(sql.length() + 20); char buf[4]; int p = 1; + bool inquote = false; for(std::string::const_iterator i = sql.begin(); i != sql.end(); i++) { - if (*i == '?') { + if (*i == '?' && !inquote) { snprintf(buf, 4, "$%d", p++); psql += buf; } + else if (*i == '\'') { + inquote = !inquote; + psql += *i; + } else { psql += *i; } -- cgit v1.2.3