def statements(self): sql_query = strip_trailing_semicolon(self.sql_query) return [ strip_trailing_semicolon(statement.strip()) for (start_row, start_col), ( end_row, end_col), statement in split_statements(sql_query) ]
def statements(self): hql_query = strip_trailing_semicolon(self.hql_query) dialect = 'hplsql' if self._data_dict['query']['type'] == 4 else None return [ strip_trailing_semicolon(statement) for (start_row, start_col), ( end_row, end_col), statement in split_statements(hql_query, dialect) ]
def teststrip_trailing_semicolon(): # Note that there are two queries (both an execute and an explain) scattered # in this file that use semicolons all the way through. # Single semicolon assert_equal("foo", strip_trailing_semicolon("foo;\n")) assert_equal("foo\n", strip_trailing_semicolon("foo\n;\n\n\n")) # Multiple semicolons: strip only last one assert_equal("fo;o;", strip_trailing_semicolon("fo;o;; ")) # No semicolons assert_equal("foo", strip_trailing_semicolon("foo"))
def hql_query(hql, database='default', query_type=None, settings=None, file_resources=None, functions=None): data_dict = HQLdesign.get_default_data_dict() if not (isinstance(hql, str) or isinstance(hql, unicode)): raise Exception('Requires a SQL text query of type <str>, <unicode> and not %s' % type(hql)) data_dict['query']['query'] = strip_trailing_semicolon(hql) data_dict['query']['database'] = database if query_type: data_dict['query']['type'] = query_type if settings is not None and HQLdesign.validate_properties('settings', settings, HQLdesign._SETTINGS_ATTRS): data_dict['settings'] = settings if file_resources is not None and HQLdesign.validate_properties('file resources', file_resources, HQLdesign._FILE_RES_ATTRS): data_dict['file_resources'] = file_resources if functions is not None and HQLdesign.validate_properties('functions', functions, HQLdesign._FUNCTIONS_ATTRS): data_dict['functions'] = functions hql_design = HQLdesign() hql_design._data_dict = data_dict return hql_design
def statements(self): hql_query = strip_trailing_semicolon(self.hql_query) return [strip_trailing_semicolon(statement) for (start_row, start_col), (end_row, end_col), statement in split_statements(hql_query)]