Hey team,
Can someone please apply the attached change to devel? I cannot compile
devel. Else I can apply it myself to master if you prefer.
Thanks,
Aleksander
On Tue, Jun 10, 2014 at 9:44 PM, Pawel Aleksander Fedorynski <
pfe...@gmail.com> wrote:
>
> Hi Denis,
>
> Yes, very good suggestion, I will try to do it later this week.
>
> Thanks,
>
> Aleksander
>
>
> On Tue, Jun 10, 2014 at 2:56 PM, Denis <babichev_de...@mail.ru> wrote:
>
>> Is it possible to add support for the assignment operator in mysql
>> backend, as in postgresql_statement_backend::prepare():
>>
>> // Check whether this is an assignment(e.g. x:=y)
>> // and treat it as a special case, not as a named binding
>> else if ((next_it != end) && (*next_it == '='))
>> {
>> query_ += ":=";
>> ++it;
>> }
>>
>> Cause expressions like these:
>> UPDATE t1 SET c1 = 2 WHERE c1 = @var1 := 1;
>> performed with an error.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
>> Find What Matters Most in Your Big Data with HPCC Systems
>> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
>> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
>> http://p.sf.net/sfu/hpccsystems
>> _______________________________________________
>> soci-users mailing list
>> soci-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/soci-users
>>
>
>
diff --git a/src/backends/mysql/statement.cpp b/src/backends/mysql/statement.cpp
index 174c8b2..f686160 100644
--- a/src/backends/mysql/statement.cpp
+++ b/src/backends/mysql/statement.cpp
@@ -71,7 +71,18 @@ void mysql_statement_backend::prepare(std::string const &
query,
}
else if (*it == ':')
{
- state = eInName;
+ const std::string::const_iterator next_it = it + 1;
+ // Check whether this is an assignment (e.g. @x:=y)
+ // and treat it as a special case, not as a named binding.
+ if (next_it != end && *next_it == '=')
+ {
+ queryChunks_.back() += ":=";
+ ++it;
+ }
+ else
+ {
+ state = eInName;
+ }
}
else // regular character, stay in the same state
{
diff --git a/src/backends/mysql/test/test-mysql.cpp
b/src/backends/mysql/test/test-mysql.cpp
index 71de331..6e3e46f 100644
--- a/src/backends/mysql/test/test-mysql.cpp
+++ b/src/backends/mysql/test/test-mysql.cpp
@@ -839,6 +839,18 @@ void test14()
std::cout << "test 14 passed" << std::endl;
}
+void test15()
+{
+ {
+ session sql(backEnd, connectString);
+ int n;
+ sql << "select @a := 123", into(n);
+ assert(n == 123);
+ }
+
+ std::cout << "test 15 passed" << std::endl;
+}
+
// DDL Creation objects for common tests
struct table_creator_one : public table_creator_base
{
@@ -976,6 +988,7 @@ int main(int argc, char** argv)
test12();
test13();
test14();
+ test15();
std::cout << "\nOK, all tests passed.\n\n";
return EXIT_SUCCESS;
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
soci-users mailing list
soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users