[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
--- a/__pkginfo__.py Fri Jun 18 15:41:39 2010 +0200
+++ b/__pkginfo__.py Fri Jun 18 18:14:55 2010 +0200
@@ -52,7 +52,7 @@
'Twisted': '',
# XXX graphviz
# server dependencies
- 'logilab-database': '',
+ 'logilab-database': '>= 1.0.4',
'pysqlite': '>= 2.5.5', # XXX install pysqlite2
}
--- a/debian/control Fri Jun 18 15:41:39 2010 +0200
+++ b/debian/control Fri Jun 18 18:14:55 2010 +0200
@@ -33,7 +33,7 @@
Conflicts: cubicweb-multisources
Replaces: cubicweb-multisources
Provides: cubicweb-multisources
-Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.0.2), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2
+Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.0.4), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2
Recommends: pyro, cubicweb-documentation (= ${source:Version})
Description: server part of the CubicWeb framework
CubicWeb is a semantic web application framework.
--- a/server/sources/rql2sql.py Fri Jun 18 15:41:39 2010 +0200
+++ b/server/sources/rql2sql.py Fri Jun 18 18:14:55 2010 +0200
@@ -1096,7 +1096,8 @@
operator = mexpr.operator
try:
if mexpr.operator == '+' and mexpr.get_type(self._state.solution, self._args) == 'String':
- operator = '||'
+ return '(%s)' % self.dbhelper.sql_concat_string(lhs.accept(self),
+ rhs.accept(self))
except CoercionError:
pass
return '(%s %s %s)'% (lhs.accept(self), operator, rhs.accept(self))
--- a/server/test/unittest_rql2sql.py Fri Jun 18 15:41:39 2010 +0200
+++ b/server/test/unittest_rql2sql.py Fri Jun 18 18:14:55 2010 +0200
@@ -1416,6 +1416,12 @@
self.o.attr_map.clear()
+ def test_concat_string(self):
+ self._check('Any "A"+R WHERE X ref R',
+ '''SELECT (A || _X.cw_ref)
+FROM cw_Affaire AS _X''')
+
+
class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC):
def setUp(self):