Projet

Général

Profil

0001-engine-conserve-table-name-case-in-SQL-queries-35130.patch

Benjamin Dauvergne, 30 juillet 2019 19:03

Télécharger (2,81 ko)

Voir les différences:

Subject: [PATCH] engine: conserve table name case in SQL queries (#35130)

 bijoe/engine.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
bijoe/engine.py
67 67
        with self.engine.get_cursor() as cursor:
68 68
            sql = self.members_query
69 69
            if not sql:
70
                table_expression = self.engine_cube.fact_table
70
                table_expression = '"%s"' % self.engine_cube.fact_table
71 71
                if self.join:
72 72
                    table_expression = self.engine_cube.build_table_expression(
73 73
                        self.join, self.engine_cube.fact_table)
......
116 116
               (self.name, self.name, self.name))
117 117
        self.members_query = sql.format(json_field=json_field)
118 118
        self.filter_expression = ('("{fact_table}".id IS NULL '
119
                                  'OR ("{fact_table}"."%s"->>\'%s\') IN (%%s))'
119
                                  'OR ("{fact_table}.%s"->>\'%s\') IN (%%s))'
120 120
                                  % (json_field, name))
121 121
        self.filter_needs_join = False
122 122

  
......
223 223

  
224 224
    def count(self):
225 225
        with self.engine.get_cursor() as cursor:
226
            cursor.execute('SELECT count(%s) FROM %s' % (self.key, self.fact_table))
226
            cursor.execute('SELECT count(%s) FROM "%s"' % (self.key, self.fact_table))
227 227
            return cursor.fetchone()[0]
228 228

  
229 229
    def get_join(self, name):
......
276 276
                if measure.expression not in projections:
277 277
                    projections.append(measure.expression + ' AS ' + measure.name)
278 278
            sql = 'SELECT ' + ', '.join(projections)
279
            table_expression = ' %s' % self.cube.fact_table
279
            table_expression = ' "%s"' % self.cube.fact_table
280 280
            if joins:
281 281
                table_expression = self.build_table_expression(
282 282
                    joins, self.fact_table, other_conditions=join_conditions)
......
330 330
            join_tree.setdefault(master_table, {}).setdefault(join.kind, {})[join.name] = join
331 331

  
332 332
        def build_table_expression_helper(join_tree, table_name, alias=None, top=True, other_conditions=None):
333
            sql = table_name
333
            if table_name.strip().startswith('('):
334
                sql = table_name
335
            else:
336
                sql = '"%s"' % table_name
334 337
            if alias:
335 338
                sql += ' AS "%s"' % alias
336 339
            add_paren = False
337
-