Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_alter_column_type_suggests_types():
q = "ALTER TABLE foo ALTER COLUMN bar TYPE "
assert set(suggest_type(q, q)) == set(
[Datatype(schema=None), Table(schema=None), Schema()]
)
def test_cast_operator_suggests_schema_qualified_types(text):
assert set(suggest_type(text, text)) == set(
[Datatype(schema="bar"), Table(schema="bar")]
)
def test_cast_operator_suggests_types(text):
assert set(suggest_type(text, text)) == set(
[Datatype(schema=None), Table(schema=None), Schema()]
)
def test_identifier_suggests_types_in_parentheses(text):
assert set(suggest_type(text, text)) == set(
[Datatype(schema=None), Table(schema=None), Schema()]
)
def test_dT_suggests_schema_or_datatypes():
text = "\\dT "
suggestions = suggest_type(text, text)
assert set(suggestions) == set([Schema(), Datatype(schema=None)])
def test_schema_qualified_dT_suggests_datatypes():
text = "\\dT foo."
suggestions = suggest_type(text, text)
assert suggestions == (Datatype(schema="foo"),)
suggestion_matchers = {
FromClauseItem: get_from_clause_item_matches,
JoinCondition: get_join_condition_matches,
Join: get_join_matches,
Column: get_column_matches,
Function: get_function_matches,
Schema: get_schema_matches,
Table: get_table_matches,
TableFormat: get_table_formats,
View: get_view_matches,
Alias: get_alias_matches,
Database: get_database_matches,
Keyword: get_keyword_matches,
Special: get_special_matches,
Datatype: get_datatype_matches,
NamedQuery: get_namedquery_matches,
Path: get_path_matches,
}
def populate_scoped_cols(self, scoped_tbls, local_tbls=()):
"""Find all columns in a set of scoped_tables.
:param scoped_tbls: list of TableReference namedtuples
:param local_tbls: tuple(TableMetadata)
:return: {TableReference:{colname:ColumnMetaData}}
"""
ctes = dict((normalize_ref(t.name), t.columns) for t in local_tbls)
columns = OrderedDict()
meta = self.dbmetadata