server/sources/rql2sql.py
branchstable
changeset 8238 087bb529035c
parent 7902 2ada3052e626
child 8245 d53762ae5961
equal deleted inserted replaced
8235:c2a91d6639d8 8238:087bb529035c
   337     Attributes related to OUTER JOIN handling
   337     Attributes related to OUTER JOIN handling
   338     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   338     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   339     * `outer_chains`, list of list of strings. Each list represent a tables
   339     * `outer_chains`, list of list of strings. Each list represent a tables
   340       that have to be outer joined together.
   340       that have to be outer joined together.
   341 
   341 
   342     * `outer_tables`, dictionnary used as index of tables used in outer join ::
   342     * `outer_tables`, dictionary used as index of tables used in outer join ::
   343 
   343 
   344         'table alias': (outertype, [conditions], [chain])
   344         'table alias': (outertype, [conditions], [chain])
   345 
   345 
   346       where:
   346       where:
   347 
   347 
   719         if attrmap is None:
   719         if attrmap is None:
   720             attrmap = {}
   720             attrmap = {}
   721         self.attr_map = attrmap
   721         self.attr_map = attrmap
   722 
   722 
   723     def generate(self, union, args=None, varmap=None):
   723     def generate(self, union, args=None, varmap=None):
   724         """return SQL queries and a variable dictionnary from a RQL syntax tree
   724         """return SQL queries and a variable dictionary from a RQL syntax tree
   725 
   725 
   726         :partrqls: a list of couple (rqlst, solutions)
   726         :partrqls: a list of couple (rqlst, solutions)
   727         :args: optional dictionary with values of substitutions used in the query
   727         :args: optional dictionary with values of substitutions used in the query
   728         :varmap: optional dictionary mapping variable name to a special table
   728         :varmap: optional dictionary mapping variable name to a special table
   729           name, in case the query as to fetch data from temporary tables
   729           name, in case the query as to fetch data from temporary tables
   770         sqls = (self.select_sql(select, needalias)
   770         sqls = (self.select_sql(select, needalias)
   771                 for i, select in enumerate(union.children))
   771                 for i, select in enumerate(union.children))
   772         return '\nUNION ALL\n'.join(sqls)
   772         return '\nUNION ALL\n'.join(sqls)
   773 
   773 
   774     def select_sql(self, select, needalias=False):
   774     def select_sql(self, select, needalias=False):
   775         """return SQL queries and a variable dictionnary from a RQL syntax tree
   775         """return SQL queries and a variable dictionary from a RQL syntax tree
   776 
   776 
   777         :select: a selection statement of the syntax tree (`rql.stmts.Select`)
   777         :select: a selection statement of the syntax tree (`rql.stmts.Select`)
   778         :solution: a dictionnary containing variables binding.
   778         :solution: a dictionary containing variables binding.
   779           A solution's dictionnary has variable's names as key and variable's
   779           A solution's dictionary has variable's names as key and variable's
   780           types as values
   780           types as values
   781         :needwrap: boolean telling if the query will be wrapped in an outer
   781         :needwrap: boolean telling if the query will be wrapped in an outer
   782           query (to deal with aggregat and/or grouping)
   782           query (to deal with aggregat and/or grouping)
   783         """
   783         """
   784         distinct = selectsortterms = select.need_distinct
   784         distinct = selectsortterms = select.need_distinct