Skip to content

Commit

Permalink
Merge pull request #1520 from fishtown-analytics/feature/rename-model…
Browse files Browse the repository at this point in the history
…s-to-select

for snapshots, make the argument "--select", not "--models" (#1517)
  • Loading branch information
beckjake authored Jun 12, 2019
2 parents 12e5bf6 + 4a10c8d commit a554b38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,13 @@ def _build_docs_generate_subparser(subparsers, base_subparser):
return generate_sub


def _add_selection_arguments(*subparsers):
def _add_selection_arguments(*subparsers, **kwargs):
models_name = kwargs.get('models_name', 'models')
for sub in subparsers:
sub.add_argument(
'-m',
'--models',
'-{}'.format(models_name[0]),
'--{}'.format(models_name),
dest='models',
required=False,
nargs='+',
help="""
Expand Down Expand Up @@ -722,7 +724,8 @@ def parse_args(args):
rpc_sub)
# --models, --exclude
_add_selection_arguments(run_sub, compile_sub, generate_sub, test_sub,
archive_sub, snapshot_sub)
archive_sub)
_add_selection_arguments(snapshot_sub, models_name='select')
# --full-refresh
_add_table_mutability_arguments(run_sub, compile_sub)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test__postgres_exclude_snapshots(self):
@use_profile('postgres')
def test__postgres_select_snapshots(self):
self.run_sql_file('seed_pg.sql')
results = self.run_dbt(['snapshot', '--models', 'snapshot_castillo'])
results = self.run_dbt(['snapshot', '--select', 'snapshot_castillo'])
self.assertEqual(len(results), 1)
self.assertTablesEqual('snapshot_castillo', 'snapshot_castillo_expected')
self.assertTableDoesNotExist('snapshot_alvarez')
Expand Down Expand Up @@ -425,7 +425,7 @@ def test__bigquery__snapshot_with_new_field(self):
# this should fail because `check="all"` will try to compare the nested field
self.run_dbt(['snapshot'], expect_pass=False)

self.run_dbt(["snapshot", '-m', 'snapshot_actual'])
self.run_dbt(["snapshot", '--select', 'snapshot_actual'])

# A more thorough test would assert that snapshotted == expected, but BigQuery does not support the
# "EXCEPT DISTINCT" operator on nested fields! Instead, just check that schemas are congruent.
Expand Down

0 comments on commit a554b38

Please sign in to comment.