merge stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 07 Apr 2010 11:57:37 +0200
branchstable
changeset 5172 865a3e522add
parent 5171 1c2567af37dd (diff)
parent 5164 4d99cccffe36 (current diff)
child 5175 6efb7a7ae570
merge
--- a/debian/control	Wed Apr 07 10:05:04 2010 +0200
+++ b/debian/control	Wed Apr 07 11:57:37 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, cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2
+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
 Recommends: pyro, cubicweb-documentation (= ${source:Version})
 Description: server part of the CubicWeb framework
  CubicWeb is a semantic web application framework.
--- a/devtools/__init__.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/devtools/__init__.py	Wed Apr 07 11:57:37 2010 +0200
@@ -200,6 +200,8 @@
         init_test_database_sqlite(config)
     elif driver == 'postgres':
         init_test_database_postgres(config)
+    elif driver == 'sqlserver2005':
+        init_test_database_sqlserver2005(config, source)
     else:
         raise ValueError('no initialization function for driver %r' % driver)
     config._cubes = None # avoid assertion error
@@ -222,11 +224,19 @@
 ### postgres test database handling ############################################
 
 def init_test_database_postgres(config):
-    """initialize a fresh sqlite databse used for testing purpose"""
+    """initialize a fresh postgresql databse used for testing purpose"""
     if config.init_repository:
         from cubicweb.server import init_repository
         init_repository(config, interactive=False, drop=True)
 
+### sqlserver2005 test database handling ############################################
+
+def init_test_database_sqlserver2005(config):
+    """initialize a fresh sqlserver databse used for testing purpose"""
+    if config.init_repository:
+        from cubicweb.server import init_repository
+        init_repository(config, interactive=False, drop=True, vreg=vreg)
+
 
 ### sqlite test database handling ##############################################
 
--- a/server/msplanner.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/server/msplanner.py	Wed Apr 07 11:57:37 2010 +0200
@@ -1042,7 +1042,7 @@
                      for select in subquery.query.children]
             for sppi in sppis:
                 if sppi.needsplit or sppi.part_sources != ppi.part_sources:
-                    temptable = 'T%s' % make_uid(id(subquery))
+                    temptable = plan.make_temp_table_name('T%s' % make_uid(id(subquery)))
                     sstep = self._union_plan(plan, sppis, temptable)[0]
                     break
             else:
@@ -1075,7 +1075,7 @@
                 inputmap = self._ppi_subqueries(ppi)
                 aggrstep = need_aggr_step(select, sources)
                 if aggrstep:
-                    atemptable = 'T%s' % make_uid(id(select))
+                    atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select)))
                     sunion = Union()
                     sunion.append(select)
                     selected = select.selection[:]
@@ -1119,7 +1119,7 @@
         subinputmap = self._ppi_subqueries(ppi)
         stepdefs = ppi.part_steps()
         if need_aggr_step(select, ppi.part_sources, stepdefs):
-            atemptable = 'T%s' % make_uid(id(select))
+            atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select)))
             selection = select.selection[:]
             select_group_sort(select)
         else:
@@ -1169,6 +1169,7 @@
                 else:
                     table = '_T%s%s' % (''.join(sorted(v._ms_table_key() for v in terms)),
                                         ''.join(sorted(str(i) for i in solindices)))
+                    table = plan.make_temp_table_name(table)
                     ppi.build_non_final_part(minrqlst, solindices, sources,
                                              insertedvars, table)
         # finally: join parts, deal with aggregat/group/sorts if necessary
--- a/server/querier.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/server/querier.py	Wed Apr 07 11:57:37 2010 +0200
@@ -164,6 +164,13 @@
         finally:
             self.clean()
 
+    def make_temp_table_name(self, table):
+        """
+        return a temp table name according to db backend
+        """
+        return self.syssource.make_temp_table_name(table)
+
+
     def init_temp_table(self, table, selected, sol):
         """initialize sql schema and variable map for a temporary table which
         will be used to store result for the given rqlst
--- a/server/repository.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/server/repository.py	Wed Apr 07 11:57:37 2010 +0200
@@ -593,7 +593,7 @@
                 raise
             except:
                 # FIXME: check error to catch internal errors
-                self.exception('unexpected error')
+                self.exception('unexpected error while executing %s with %s', rqlstring, args)
                 raise
         finally:
             session.reset_pool()
--- a/server/sources/native.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/server/sources/native.py	Wed Apr 07 11:57:37 2010 +0200
@@ -669,6 +669,15 @@
             pass
         return None
 
+    def make_temp_table_name(self, table):
+        try: # XXX remove this once 
+            return self.dbhelper.temporary_table_name(table)
+        except AttributeError:
+            import warnings
+            warnings.warn('Please hg up logilab.database')
+            return table
+
+
     def temp_table_def(self, selected, sol, table):
         return make_schema(selected, sol, table, self.dbhelper.TYPE_MAPPING)
 
--- a/skeleton/test/pytestconf.py	Wed Apr 07 10:05:04 2010 +0200
+++ b/skeleton/test/pytestconf.py	Wed Apr 07 11:57:37 2010 +0200
@@ -26,11 +26,11 @@
     parser.add_option('-u', '--dbuser', dest='dbuser', action='store',
                       default=login, help="database user")
     parser.add_option('-w', '--dbpassword', dest='dbpassword', action='store',
-                      default=login, help="database name")
+                      default=login, help="database user's password")
     parser.add_option('-n', '--dbname', dest='dbname', action='store',
                       default=None, help="database name")
     parser.add_option('--euser', dest='euser', action='store',
-                      default=login, help="esuer name")
+                      default=login, help="euser name")
     parser.add_option('--epassword', dest='epassword', action='store',
                       default=login, help="euser's password' name")
     return parser