Skip to content

AttributeError: 'NoneType' object has no attribute 'value' #253

@zshandy

Description

@zshandy

Hi, I am using this library for extracting columns and tables from a view definition, and when I run it against a view definition, it shows the following error:

AttributeError Traceback (most recent call last)
in
----> 1 Parser(str1).columns

G:\Anaconda3\envs\py36\lib\site-packages\sql_metadata\parser.py in columns(self)
211 and not token.is_conversion_specifier
212 ):
--> 213 self._handle_column_save(token=token, columns=columns)
214
215 elif token.is_column_name_inside_insert_clause:

G:\Anaconda3\envs\py36\lib\site-packages\sql_metadata\parser.py in _handle_column_save(self, token, columns)
629 token.token_type = TokenType.COLUMN_ALIAS
630 return
--> 631 column = self._resolve_sub_queries(column)
632 self._add_to_columns_with_tables(token, column)
633 self._add_to_columns_subsection(

G:\Anaconda3\envs\py36\lib\site-packages\sql_metadata\parser.py in _resolve_sub_queries(self, column)
767 subquery_alias=column,
768 nested_queries_names=self.subqueries_names,
--> 769 nested_queries=self.subqueries,
770 already_parsed=self._subqueries_parsers,
771 )

G:\Anaconda3\envs\py36\lib\site-packages\sql_metadata\parser.py in subqueries(self)
518 query_name = inner_token.next_token.value
519 else:
--> 520 query_name = inner_token.next_token.next_token.value
521 subquery_text = "".join([x.stringified_token for x in current_subquery])
522 subqueries[query_name] = subquery_text

AttributeError: 'NoneType' object has no attribute 'value'

Here is a snippet of the view definition generated by the database that caused that issue(it is MySQL and can run successfully in a MySQL console):

select t.symbol AS symbol from (stock.top_momentum_sector s join stock.daily_companies t on((s.symbol = t.symbol)))

Thanks a lot in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions