summaryrefslogtreecommitdiff
path: root/libpqpp/command.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-13 21:02:18 +0000
committerrandomdan <randomdan@localhost>2011-02-13 21:02:18 +0000
commitc94daa95e01e9b8d4c941e344268b8d7bdc4b688 (patch)
tree6141d4fc0570fdfd2c2640316f5efefb4a39009f /libpqpp/command.cpp
parentMinor tweaks to improve perforamce on PG bulk deletes (diff)
downloadlibdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.tar.bz2
libdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.tar.xz
libdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.zip
Fixed handling of ?s in string literals
Diffstat (limited to 'libpqpp/command.cpp')
-rw-r--r--libpqpp/command.cpp7
1 files changed, 6 insertions, 1 deletions
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;
}