Skip to content

Commit

Permalink
SNOW-1011774: Fixing type of scope option for 'object list' to be opt…
Browse files Browse the repository at this point in the history
…ional.
  • Loading branch information
sfc-gh-davwang committed Jan 26, 2024
1 parent 1c74ab6 commit b7b578a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/snowflake/cli/plugins/object/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def _scope_callback(scope: Tuple[str, str]):
raise ClickException(
f'scope must be one of the following: {", ".join(VALID_SCOPES)}'
)
if scope[0] is None or scope[1] is None:
return None
return scope


Expand All @@ -65,7 +67,7 @@ def _scope_callback(scope: Tuple[str, str]):
@global_options_with_connection
def list_(
object_type: str = ObjectArgument,
like: Optional[str] = LikeOption,
like: str = LikeOption,
scope: Optional[Tuple[str, str]] = ScopeOption,
**options,
):
Expand Down
4 changes: 2 additions & 2 deletions src/snowflake/cli/plugins/object/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def show(
*,
object_type: str,
like: Optional[str] = None,
scope: Tuple[str, str],
scope: Optional[Tuple[str, str]] = None,
**kwargs,
) -> SnowflakeCursor:
object_name = _get_object_names(object_type).sf_plural_name
query = f"show {object_name}"
if like:
query += f" like '{like}'"
if scope[0] and scope[1]:
if scope is not None:
query += f" in {scope[0].replace('-', ' ')} {scope[1]}"
return self._execute_query(query, **kwargs)

Expand Down
4 changes: 3 additions & 1 deletion src/snowflake/cli/plugins/snowpark/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def _check_if_all_defined_integrations_exists(
):
existing_integrations = {
i["name"].lower()
for i in om.show(object_type="integration", cursor_class=DictCursor, like=None)
for i in om.show(
object_type="integration", cursor_class=DictCursor, like=None, scope=None
)
if i["type"] == "EXTERNAL_ACCESS"
}
declared_integration: Set[str] = set()
Expand Down

0 comments on commit b7b578a

Please sign in to comment.