def set_source_context(self, context): self.set_linecol(context.start.line, context.start.column) ex.replace_context(self, context) if context.start is not None: self._attrs[FIELD_POSITION_START] = str(context.start.pointer) self._attrs[FIELD_POSITION_END] = str(context.end.pointer)
def set_hint_and_details(self, hint, details=None): ex.replace_context( self, ex.DefaultExceptionContext(hint=hint, details=details)) if hint is not None: self._attrs[FIELD_HINT] = hint if details is not None: self._attrs[FIELD_DETAILS] = details
async def _execute_ddl(conn, sql_text): try: if debug.flags.bootstrap: debug.header('Delta Script') debug.dump_code(sql_text, lexer='sql') await conn.execute(sql_text) except Exception as e: position = getattr(e, 'position', None) internal_position = getattr(e, 'internal_position', None) context = getattr(e, 'context', '') if context: pl_func_line = re.search( r'^PL/pgSQL function inline_code_block line (\d+).*', context, re.M) if pl_func_line: pl_func_line = int(pl_func_line.group(1)) else: pl_func_line = None point = None if position is not None: position = int(position) point = parser_context.SourcePoint( None, None, position) text = e.query if text is None: # Parse errors text = sql_text elif internal_position is not None: internal_position = int(internal_position) point = parser_context.SourcePoint( None, None, internal_position) text = e.internal_query elif pl_func_line: point = parser_context.SourcePoint( pl_func_line, None, None ) text = sql_text if point is not None: context = parser_context.ParserContext( 'query', text, start=point, end=point) exceptions.replace_context(e, context) raise
def set_source_context(self, context): start = context.start_point end = context.end_point ex.replace_context(self, context) self._attrs[FIELD_POSITION_START] = str(start.offset) self._attrs[FIELD_POSITION_END] = str(end.offset) self._attrs[FIELD_CHARACTER_START] = str(start.char_offset) self._attrs[FIELD_CHARACTER_END] = str(end.char_offset) self._attrs[FIELD_LINE_START] = str(start.line) self._attrs[FIELD_COLUMN_START] = str(start.column) self._attrs[FIELD_UTF16_COLUMN_START] = str(start.utf16column) self._attrs[FIELD_LINE_END] = str(end.line) self._attrs[FIELD_COLUMN_END] = str(end.column) self._attrs[FIELD_UTF16_COLUMN_END] = str(end.utf16column)