Skip to content

Commit

Permalink
SNOW-1011774: Changing default for '--in' to (None, None) due to lack…
Browse files Browse the repository at this point in the history
… of typer CLI support for optional tuples
  • Loading branch information
sfc-gh-davwang committed Jan 26, 2024
1 parent b7b578a commit 8938f6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/snowflake/cli/plugins/object/commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Optional, Tuple
from typing import Tuple

import typer
from click import ClickException
Expand Down Expand Up @@ -44,8 +44,6 @@ 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 @@ -68,7 +66,7 @@ def _scope_callback(scope: Tuple[str, str]):
def list_(
object_type: str = ObjectArgument,
like: str = LikeOption,
scope: Optional[Tuple[str, str]] = ScopeOption,
scope: Tuple[str, str] = ScopeOption,
**options,
):
return QueryResult(
Expand Down
6 changes: 3 additions & 3 deletions src/snowflake/cli/plugins/object/manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Optional, Tuple
from typing import Optional, Tuple, Union

from click import ClickException
from snowflake.cli.api.constants import OBJECT_TO_NAMES, ObjectNames
Expand All @@ -21,14 +21,14 @@ def show(
*,
object_type: str,
like: Optional[str] = None,
scope: Optional[Tuple[str, str]] = None,
scope: Union[Tuple[str, str], Tuple[None, None]] = (None, 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 is not None:
if scope[0] is not None:
query += f" in {scope[0].replace('-', ' ')} {scope[1]}"
return self._execute_query(query, **kwargs)

Expand Down

0 comments on commit 8938f6e

Please sign in to comment.