Skip to content

[FEATURE] Table to ignore#6

Merged
jasdeepkhalsa merged 1 commit intoDBDiff:masterfrom
webian:master
May 16, 2016
Merged

[FEATURE] Table to ignore#6
jasdeepkhalsa merged 1 commit intoDBDiff:masterfrom
webian:master

Conversation

@webian
Copy link
Copy Markdown
Contributor

@webian webian commented May 14, 2016

Tables to ignore from the check can be set in the .dbdiff config file with a YAML collection:

tablesToExclude:
- table1
- table2
- table3

@jasdeepkhalsa
Copy link
Copy Markdown
Member

Strangely, I actually prefer your first PR as it means there's only one high level instantiation of the ParamsFactory class and the params flow down from there, meaning we can be sure the are the same everywhere in the code base - any particular reason you decided to go this way instead?

@webian
Copy link
Copy Markdown
Contributor Author

webian commented May 14, 2016

The reason is that I'm working on expanding that feature allowing also to ignore fields of certain tables with a YAML config like:

    fieldsToIgnore:
        table1:
            - field1
            - field2
            - field3
        table4:
            - field1
            - field4

To achieve this I need the params in the method getChangeDiff that is too much nested and with the first PR method would be complicated to pass the params through all those methods.

Btw, I found an even better solution IMHO that is to make static the method get() of ParamsFactory so it can be called directly using namespaces.

I updated the commit adding also the possibility to ignore fields.

Do you like this approach better?

@jasdeepkhalsa
Copy link
Copy Markdown
Member

This is fantastic work! And the ability to ignore fields on tables is something I think users of DBDiff would really appreciate! I'll merge this in as it is :)

@jasdeepkhalsa jasdeepkhalsa merged commit cddf9b1 into DBDiff:master May 16, 2016
jasdeepkhalsa added a commit that referenced this pull request Mar 25, 2026
MySQLAdapter::getTables() now uses SHOW FULL TABLES WHERE Table_type =
'BASE TABLE' instead of SHOW TABLES, preventing views from entering the
diff pipeline and being incorrectly handled as tables (which would
generate DROP TABLE instead of DROP VIEW).

PostgreSQL and SQLite adapters were already correct — pg_tables only
includes base tables and SQLite filters type = 'table'.

Added unit tests for DropTableSQL and AddTableSQL output verification.

Refs: bugs.md Bug #6, PR #123
jasdeepkhalsa added a commit that referenced this pull request Mar 25, 2026
Bug #3 — Hyphenated database names (End2EndTest::testHyphenatedDatabaseNames)
  Runs the full MySQL end-to-end diff with databases named 'diff-1'/'diff-2'.
  Before the fix, unquoted hyphens caused MySQL error 1064. The test asserts
  that DBDiff completes, writes output, and that output matches the standard
  baseline (same schema/data, only the DB name differs).

Bug #6 — Views excluded from diff (AbstractComprehensiveTest::testViewsExcludedFromDiff)
  New fixture 'views_ignored': source DB has a TABLE 'products' + VIEW
  'active_products'; target DB has only the table with an extra column.
  Test asserts 'active_products' never appears in the diff output, while the
  real schema difference (price column) is still detected.
  Fixture files added for MySQL, PostgreSQL, and SQLite.

Bug #7 — NULL column changes detected (AbstractComprehensiveTest::testNullableColumnDataDetected)
  New fixture 'nullable_data': rows 1 and 2 have NULL<->value changes in a
  nullable column; row 3 has NULL in both source and target (must be ignored).
  Test asserts UPDATE statements are generated and row 3 is absent.
  Fixture files added for MySQL, PostgreSQL, and SQLite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants