sqlmeta.comparison

SQL object comparison and schema drift detection.

This module provides functionality to compare SQL objects from different sources and detect schema drift.

Example

>>> from sqlmeta.comparison import ObjectComparator, DataTypeNormalizer
>>> normalizer = DataTypeNormalizer("postgresql")
>>> comparator = ObjectComparator(normalizer)
>>> diff = comparator.compare_tables(table1, table2)
class sqlmeta.comparison.ObjectComparator(type_normalizer: DataTypeNormalizer)[source]

Compares SQL Model objects and generates diff results.

This class provides methods to compare SQL objects from different sources (e.g., parsed SQL scripts vs. database metadata) and identify differences.

Example

>>> normalizer = DataTypeNormalizer()
>>> comparator = ObjectComparator(normalizer)
>>> diff = comparator.compare_tables(script_table, db_table, "postgresql")
>>> if diff.has_diffs:
...     print(f"Found differences: {diff}")
__init__(type_normalizer: DataTypeNormalizer)[source]

Initialize the object comparator.

Parameters:

type_normalizer – DataTypeNormalizer for type comparison

Compare two database link objects (Oracle).

Parameters:
  • expected – Expected database link from migrations

  • actual – Actual database link from database

  • dialect – SQL dialect (typically oracle)

Returns:

DatabaseLinkDiff if differences found, None otherwise

compare_events(expected: Event, actual: Event, dialect: str = 'mysql') EventDiff | None[source]

Compare two event objects (MySQL).

Parameters:
  • expected – Expected event from migrations

  • actual – Actual event from database

  • dialect – SQL dialect (typically mysql)

Returns:

EventDiff if differences found, None otherwise

compare_extensions(expected: Extension, actual: Extension, dialect: str = 'postgresql') ExtensionDiff | None[source]

Compare two extension objects (PostgreSQL).

Parameters:
  • expected – Expected extension from migrations

  • actual – Actual extension from database

  • dialect – SQL dialect (typically postgresql)

Returns:

ExtensionDiff if differences found, None otherwise

compare_foreign_data_wrappers(expected: ForeignDataWrapper, actual: ForeignDataWrapper, dialect: str = 'postgresql') ForeignDataWrapperDiff | None[source]

Compare two foreign data wrapper objects (PostgreSQL).

Parameters:
  • expected – Expected FDW from migrations

  • actual – Actual FDW from database

  • dialect – SQL dialect (typically postgresql)

Returns:

ForeignDataWrapperDiff if differences found, None otherwise

compare_foreign_servers(expected: ForeignServer, actual: ForeignServer, dialect: str = 'postgresql') ForeignServerDiff | None[source]

Compare two foreign server objects (PostgreSQL).

Parameters:
  • expected – Expected foreign server from migrations

  • actual – Actual foreign server from database

  • dialect – SQL dialect (typically postgresql)

Returns:

ForeignServerDiff if differences found, None otherwise

compare_functions(expected: Procedure, actual: Procedure, dialect: str = 'postgresql') FunctionDiff | None[source]

Compare two function objects (Procedure with is_function=True).

Parameters:
  • expected – Expected function from migrations (Procedure with is_function=True)

  • actual – Actual function from database (Procedure with is_function=True)

  • dialect – SQL dialect

Returns:

FunctionDiff if differences found, None otherwise

compare_indexes(expected: Index, actual: Index, dialect: str = 'postgresql') IndexDiff | None[source]

Compare two index objects.

Parameters:
  • expected – Expected index from migrations

  • actual – Actual index from database

  • dialect – SQL dialect

Returns:

IndexDiff if differences found, None otherwise

compare_linked_servers(expected: LinkedServer, actual: LinkedServer, dialect: str = 'sqlserver') LinkedServerDiff | None[source]

Compare two linked server objects (SQL Server).

Parameters:
  • expected – Expected linked server from migrations

  • actual – Actual linked server from database

  • dialect – SQL dialect (typically sqlserver)

Returns:

LinkedServerDiff if differences found, None otherwise

compare_modules(expected: Module, actual: Module, dialect: str = 'db2') ModuleDiff | None[source]

Compare two DB2 module objects.

Parameters:
  • expected – Expected module from migrations

  • actual – Actual module from database

  • dialect – SQL dialect (typically db2)

Returns:

ModuleDiff if differences found, None otherwise

compare_packages(expected: Package, actual: Package, dialect: str = 'oracle') PackageDiff | None[source]

Compare two package objects (Oracle).

Parameters:
  • expected – Expected package from migrations

  • actual – Actual package from database

  • dialect – SQL dialect (typically oracle)

Returns:

PackageDiff if differences found, None otherwise

compare_procedures(expected: Procedure, actual: Procedure, dialect: str = 'postgresql') ProcedureDiff | None[source]

Compare two procedure objects.

Parameters:
  • expected – Expected procedure from migrations

  • actual – Actual procedure from database

  • dialect – SQL dialect

Returns:

ProcedureDiff if differences found, None otherwise

compare_schemas(expected_tables: List[Table], actual_tables: List[Table], dialect: str = 'postgresql', schema_name: str = 'public') SchemaDiff[source]

Compare lists of tables from two schemas.

Parameters:
  • expected_tables – Expected tables (from scripts)

  • actual_tables – Actual tables (from database)

  • dialect – SQL dialect for type normalization

  • schema_name – Name of the schema being compared

Returns:

SchemaDiff object with comparison results

compare_sequences(expected: Sequence, actual: Sequence, dialect: str = 'postgresql') SequenceDiff | None[source]

Compare two sequence objects.

Parameters:
  • expected – Expected sequence from migrations

  • actual – Actual sequence from database

  • dialect – SQL dialect

Returns:

SequenceDiff if differences found, None otherwise

compare_synonyms(expected: Synonym, actual: Synonym, dialect: str = 'postgresql') SynonymDiff | None[source]

Compare two synonym objects.

Parameters:
  • expected – Expected synonym from migrations

  • actual – Actual synonym from database

  • dialect – SQL dialect

Returns:

SynonymDiff if differences found, None otherwise

compare_tables(expected: Table, actual: Table, dialect: str = 'postgresql') TableDiff[source]

Compare two table objects.

Parameters:
  • expected – Expected table (from scripts)

  • actual – Actual table (from database)

  • dialect – SQL dialect for type normalization

Returns:

TableDiff object with comparison results

Example

>>> diff = comparator.compare_tables(script_table, db_table, "postgresql")
>>> print(f"Missing columns: {diff.missing_columns}")
compare_triggers(expected: Trigger, actual: Trigger, dialect: str = 'postgresql') TriggerDiff | None[source]

Compare two trigger objects.

Parameters:
  • expected – Expected trigger from migrations

  • actual – Actual trigger from database

  • dialect – SQL dialect

Returns:

TriggerDiff if differences found, None otherwise

compare_user_defined_types(expected: UserDefinedType, actual: UserDefinedType, dialect: str = 'postgresql') UserDefinedTypeDiff | None[source]

Compare two user-defined type objects.

Parameters:
  • expected – Expected UDT from migrations

  • actual – Actual UDT from database

  • dialect – SQL dialect

Returns:

UserDefinedTypeDiff if differences found, None otherwise

compare_views(expected: View, actual: View, dialect: str = 'postgresql') ViewDiff | None[source]

Compare two view objects.

Parameters:
  • expected – Expected view from migrations

  • actual – Actual view from database

  • dialect – SQL dialect

Returns:

ViewDiff if differences found, None otherwise

class sqlmeta.comparison.DataTypeNormalizer[source]

Normalizes data types across SQL dialects for comparison.

This class handles dialect-specific type equivalences, precision/scale normalization, and cross-dialect type mapping to enable accurate comparison of SQL Model objects from different sources.

Example

>>> normalizer = DataTypeNormalizer()
>>> normalizer.normalize("INT", "postgresql")
'INTEGER'
>>> normalizer.normalize("VARCHAR2(100)", "oracle")
'VARCHAR(100)'
>>> normalizer.normalize("TINYINT(1)", "mysql")
'BOOLEAN'
__init__()[source]

Initialize the data type normalizer.

are_equivalent(type1: str, type2: str, dialect1: str, dialect2: str) bool[source]

Check if two data types are equivalent across dialects.

Parameters:
  • type1 – First data type

  • type2 – Second data type

  • dialect1 – Dialect of first type

  • dialect2 – Dialect of second type

Returns:

True if types are equivalent, False otherwise

Example

>>> normalizer.are_equivalent("TEXT", "CLOB", "postgresql", "oracle")
True
>>> normalizer.are_equivalent("INT", "VARCHAR", "mysql", "mysql")
False
extract_precision_scale(data_type: str) Tuple[int | None, int | None][source]

Extract precision and scale from a data type string.

Parameters:

data_type – Data type with optional precision/scale (e.g., “NUMBER(10,2)”)

Returns:

Tuple of (precision, scale), both may be None

Example

>>> normalizer.extract_precision_scale("VARCHAR(100)")
(100, None)
>>> normalizer.extract_precision_scale("NUMBER(10,2)")
(10, 2)
normalize(data_type: str, dialect: str, precision: int | None = None, scale: int | None = None) str[source]

Normalize a data type for the given dialect.

Parameters:
  • data_type – The data type to normalize (e.g., “INT”, “VARCHAR2”)

  • dialect – The SQL dialect (postgresql, oracle, mysql, sqlserver, db2)

  • precision – Optional precision value

  • scale – Optional scale value

Returns:

Normalized data type string

Example

>>> normalizer.normalize("INT", "postgresql")
'INTEGER'
>>> normalizer.normalize("NUMBER", "oracle", 10, 2)
'NUMBER(10,2)'
class sqlmeta.comparison.DiffResult(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False)[source]

Base class for comparison results.

object_name

Name of the object being compared

Type:

str

object_type

Type of object (table, view, procedure, etc.)

Type:

str

severity

Highest severity of differences found

Type:

sqlmeta.comparison.diff_models.DiffSeverity

has_diffs

Whether any differences were found

Type:

bool

__init__(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False) None
__str__() str[source]

Human-readable string representation.

Returns:

Formatted string describing the diff

get_summary() str[source]

Get a brief summary of differences.

Returns:

Brief summary string

has_diffs: bool = False
object_type: str = ''
severity: DiffSeverity = 'info'
to_dict() Dict[str, Any][source]

Convert to dictionary for serialization.

Returns:

Dictionary representation of the diff result

object_name: str
class sqlmeta.comparison.TableDiff(object_name: str, object_type: str = '', severity: ~sqlmeta.comparison.diff_models.DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, table_name: str = '', missing_columns: ~typing.List[str] = <factory>, extra_columns: ~typing.List[str] = <factory>, modified_columns: ~typing.List[~sqlmeta.comparison.diff_models.ColumnDiff] = <factory>, missing_constraints: ~typing.List[str] = <factory>, extra_constraints: ~typing.List[str] = <factory>, modified_constraints: ~typing.List[~sqlmeta.comparison.diff_models.ConstraintDiff] = <factory>, missing_indexes: ~typing.List[str] = <factory>, extra_indexes: ~typing.List[str] = <factory>, temporary_changed: bool = False, filegroup_changed: bool = False, memory_optimized_changed: bool = False, system_versioned_changed: bool = False, history_table_changed: bool = False, partition_method_changed: bool = False, partition_columns_changed: bool = False, compress_changed: bool = False, compress_type_changed: bool = False, logged_changed: bool = False, organize_by_changed: bool = False)[source]

Represents differences in a table definition.

table_name

Name of the table

Type:

str

missing_columns

Columns in expected but not in actual

Type:

List[str]

extra_columns

Columns in actual but not in expected

Type:

List[str]

modified_columns

Columns with differences

Type:

List[sqlmeta.comparison.diff_models.ColumnDiff]

missing_constraints

Constraints in expected but not in actual

Type:

List[str]

extra_constraints

Constraints in actual but not in expected

Type:

List[str]

modified_constraints

Constraints with differences

Type:

List[sqlmeta.comparison.diff_models.ConstraintDiff]

missing_indexes

Indexes in expected but not in actual

Type:

List[str]

extra_indexes

Indexes in actual but not in expected

Type:

List[str]

temporary_changed

Whether temporary property changed (grammar-based enhancement)

Type:

bool

filegroup_changed

Whether filegroup changed (T-SQL grammar-based)

Type:

bool

memory_optimized_changed

Whether memory-optimized property changed (T-SQL grammar-based)

Type:

bool

system_versioned_changed

Whether system-versioned property changed (T-SQL grammar-based)

Type:

bool

history_table_changed

Whether history table changed (T-SQL grammar-based)

Type:

bool

partition_method_changed

Whether partition method changed (partition scheme tracking)

Type:

bool

partition_columns_changed

Whether partition columns changed (partition scheme tracking)

Type:

bool

compress_changed

Whether compress property changed (DB2 grammar-based)

Type:

bool

compress_type_changed

Whether compress type changed (DB2 grammar-based)

Type:

bool

logged_changed

Whether logged property changed (DB2 grammar-based)

Type:

bool

organize_by_changed

Whether organize_by property changed (DB2 grammar-based)

Type:

bool

__init__(object_name: str, object_type: str = '', severity: ~sqlmeta.comparison.diff_models.DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, table_name: str = '', missing_columns: ~typing.List[str] = <factory>, extra_columns: ~typing.List[str] = <factory>, modified_columns: ~typing.List[~sqlmeta.comparison.diff_models.ColumnDiff] = <factory>, missing_constraints: ~typing.List[str] = <factory>, extra_constraints: ~typing.List[str] = <factory>, modified_constraints: ~typing.List[~sqlmeta.comparison.diff_models.ConstraintDiff] = <factory>, missing_indexes: ~typing.List[str] = <factory>, extra_indexes: ~typing.List[str] = <factory>, temporary_changed: bool = False, filegroup_changed: bool = False, memory_optimized_changed: bool = False, system_versioned_changed: bool = False, history_table_changed: bool = False, partition_method_changed: bool = False, partition_columns_changed: bool = False, compress_changed: bool = False, compress_type_changed: bool = False, logged_changed: bool = False, organize_by_changed: bool = False) None
__post_init__()[source]

Calculate has_diffs and severity after initialization.

__str__() str[source]

Human-readable string representation.

compress_changed: bool = False
compress_type_changed: bool = False
filegroup_changed: bool = False
get_diff_count() Dict[str, int][source]

Get count of each type of difference.

Returns:

Dictionary with counts of different types

history_table_changed: bool = False
logged_changed: bool = False
memory_optimized_changed: bool = False
organize_by_changed: bool = False
partition_columns_changed: bool = False
partition_method_changed: bool = False
system_versioned_changed: bool = False
table_name: str = ''
temporary_changed: bool = False
to_dict() Dict[str, Any][source]

Convert to dictionary for serialization.

missing_columns: List[str]
extra_columns: List[str]
modified_columns: List[ColumnDiff]
missing_constraints: List[str]
extra_constraints: List[str]
modified_constraints: List[ConstraintDiff]
missing_indexes: List[str]
extra_indexes: List[str]
class sqlmeta.comparison.ColumnDiff(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, column_name: str = '', data_type_diff: tuple | None = None, nullable_diff: tuple | None = None, default_diff: tuple | None = None, identity_diff: tuple | None = None, computed_diff: tuple | None = None)[source]

Represents differences in a column definition.

column_name

Name of the column

Type:

str

data_type_diff

Data type differences (expected vs actual)

Type:

tuple | None

nullable_diff

Nullability differences

Type:

tuple | None

default_diff

Default value differences

Type:

tuple | None

identity_diff

Identity column differences

Type:

tuple | None

computed_diff

Computed column differences

Type:

tuple | None

__init__(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, column_name: str = '', data_type_diff: tuple | None = None, nullable_diff: tuple | None = None, default_diff: tuple | None = None, identity_diff: tuple | None = None, computed_diff: tuple | None = None) None
__post_init__()[source]

Calculate has_diffs and severity after initialization.

__str__() str[source]

Human-readable string representation.

column_name: str = ''
computed_diff: tuple | None = None
data_type_diff: tuple | None = None
default_diff: tuple | None = None
identity_diff: tuple | None = None
nullable_diff: tuple | None = None
to_dict() Dict[str, Any][source]

Convert to dictionary for serialization.

class sqlmeta.comparison.ConstraintDiff(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, constraint_name: str = '', constraint_type: str = '', columns_diff: tuple | None = None, references_diff: tuple | None = None, check_clause_diff: tuple | None = None)[source]

Represents differences in a constraint definition.

constraint_name

Name of the constraint

Type:

str

constraint_type

Type of constraint (PK, FK, UNIQUE, CHECK)

Type:

str

columns_diff

Differences in constrained columns

Type:

tuple | None

references_diff

Differences in foreign key references

Type:

tuple | None

check_clause_diff

Differences in CHECK constraint expressions

Type:

tuple | None

__init__(object_name: str, object_type: str = '', severity: DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, constraint_name: str = '', constraint_type: str = '', columns_diff: tuple | None = None, references_diff: tuple | None = None, check_clause_diff: tuple | None = None) None
__post_init__()[source]

Calculate has_diffs and severity after initialization.

__str__() str[source]

Human-readable string representation.

check_clause_diff: tuple | None = None
columns_diff: tuple | None = None
constraint_name: str = ''
constraint_type: str = ''
references_diff: tuple | None = None
to_dict() Dict[str, Any][source]

Convert to dictionary for serialization.

class sqlmeta.comparison.SchemaDiff(object_name: str, object_type: str = '', severity: ~sqlmeta.comparison.diff_models.DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, schema_name: str = '', missing_tables: ~typing.List[str] = <factory>, extra_tables: ~typing.List[str] = <factory>, modified_tables: ~typing.List[~sqlmeta.comparison.diff_models.TableDiff] = <factory>, missing_views: ~typing.List[str] = <factory>, extra_views: ~typing.List[str] = <factory>, modified_views: ~typing.List[~sqlmeta.comparison.diff_models.ViewDiff] = <factory>, missing_indexes: ~typing.List[str] = <factory>, extra_indexes: ~typing.List[str] = <factory>, modified_indexes: ~typing.List[~sqlmeta.comparison.diff_models.IndexDiff] = <factory>, missing_sequences: ~typing.List[str] = <factory>, extra_sequences: ~typing.List[str] = <factory>, modified_sequences: ~typing.List[~sqlmeta.comparison.diff_models.SequenceDiff] = <factory>, missing_triggers: ~typing.List[str] = <factory>, extra_triggers: ~typing.List[str] = <factory>, modified_triggers: ~typing.List[~sqlmeta.comparison.diff_models.TriggerDiff] = <factory>, missing_procedures: ~typing.List[str] = <factory>, extra_procedures: ~typing.List[str] = <factory>, modified_procedures: ~typing.List[~sqlmeta.comparison.diff_models.ProcedureDiff] = <factory>, missing_functions: ~typing.List[str] = <factory>, extra_functions: ~typing.List[str] = <factory>, modified_functions: ~typing.List[~sqlmeta.comparison.diff_models.FunctionDiff] = <factory>, missing_synonyms: ~typing.List[str] = <factory>, extra_synonyms: ~typing.List[str] = <factory>, modified_synonyms: ~typing.List[~sqlmeta.comparison.diff_models.SynonymDiff] = <factory>, missing_packages: ~typing.List[str] = <factory>, extra_packages: ~typing.List[str] = <factory>, modified_packages: ~typing.List[~sqlmeta.comparison.diff_models.PackageDiff] = <factory>, missing_modules: ~typing.List[str] = <factory>, extra_modules: ~typing.List[str] = <factory>, modified_modules: ~typing.List[~sqlmeta.comparison.diff_models.ModuleDiff] = <factory>, missing_database_links: ~typing.List[str] = <factory>, extra_database_links: ~typing.List[str] = <factory>, modified_database_links: ~typing.List[~sqlmeta.comparison.diff_models.DatabaseLinkDiff] = <factory>, missing_linked_servers: ~typing.List[str] = <factory>, extra_linked_servers: ~typing.List[str] = <factory>, modified_linked_servers: ~typing.List[~sqlmeta.comparison.diff_models.LinkedServerDiff] = <factory>, missing_foreign_data_wrappers: ~typing.List[str] = <factory>, extra_foreign_data_wrappers: ~typing.List[str] = <factory>, modified_foreign_data_wrappers: ~typing.List[~sqlmeta.comparison.diff_models.ForeignDataWrapperDiff] = <factory>, missing_foreign_servers: ~typing.List[str] = <factory>, extra_foreign_servers: ~typing.List[str] = <factory>, modified_foreign_servers: ~typing.List[~sqlmeta.comparison.diff_models.ForeignServerDiff] = <factory>, missing_extensions: ~typing.List[str] = <factory>, extra_extensions: ~typing.List[str] = <factory>, modified_extensions: ~typing.List[~sqlmeta.comparison.diff_models.ExtensionDiff] = <factory>, missing_events: ~typing.List[str] = <factory>, extra_events: ~typing.List[str] = <factory>, modified_events: ~typing.List[~sqlmeta.comparison.diff_models.EventDiff] = <factory>, missing_user_defined_types: ~typing.List[str] = <factory>, extra_user_defined_types: ~typing.List[str] = <factory>, modified_user_defined_types: ~typing.List[~sqlmeta.comparison.diff_models.UserDefinedTypeDiff] = <factory>)[source]

Represents schema-level comparison results.

schema_name

Name of the schema

Type:

str

missing_tables

Tables in expected but not in actual

Type:

List[str]

extra_tables

Tables in actual but not in expected

Type:

List[str]

modified_tables

Tables with differences

Type:

List[sqlmeta.comparison.diff_models.TableDiff]

missing_views

Views in expected but not in actual

Type:

List[str]

extra_views

Views in actual but not in expected

Type:

List[str]

modified_views

Views with differences

Type:

List[sqlmeta.comparison.diff_models.ViewDiff]

missing_indexes

Indexes in expected but not in actual

Type:

List[str]

extra_indexes

Indexes in actual but not in expected

Type:

List[str]

modified_indexes

Indexes with differences

Type:

List[sqlmeta.comparison.diff_models.IndexDiff]

missing_sequences

Sequences in expected but not in actual

Type:

List[str]

extra_sequences

Sequences in actual but not in expected

Type:

List[str]

modified_sequences

Sequences with differences

Type:

List[sqlmeta.comparison.diff_models.SequenceDiff]

missing_triggers

Triggers in expected but not in actual

Type:

List[str]

extra_triggers

Triggers in actual but not in expected

Type:

List[str]

modified_triggers

Triggers with differences

Type:

List[sqlmeta.comparison.diff_models.TriggerDiff]

missing_procedures

Procedures in expected but not in actual

Type:

List[str]

extra_procedures

Procedures in actual but not in expected

Type:

List[str]

modified_procedures

Procedures with differences

Type:

List[sqlmeta.comparison.diff_models.ProcedureDiff]

missing_functions

Functions in expected but not in actual

Type:

List[str]

extra_functions

Functions in actual but not in expected

Type:

List[str]

modified_functions

Functions with differences

Type:

List[sqlmeta.comparison.diff_models.FunctionDiff]

missing_synonyms

Synonyms in expected but not in actual

Type:

List[str]

extra_synonyms

Synonyms in actual but not in expected

Type:

List[str]

modified_synonyms

Synonyms with differences

Type:

List[sqlmeta.comparison.diff_models.SynonymDiff]

missing_packages

Packages in expected but not in actual

Type:

List[str]

extra_packages

Packages in actual but not in expected

Type:

List[str]

modified_packages

Packages with differences

Type:

List[sqlmeta.comparison.diff_models.PackageDiff]

missing_extensions

Extensions in expected but not in actual

Type:

List[str]

extra_extensions

Extensions in actual but not in expected

Type:

List[str]

modified_extensions

Extensions with differences

Type:

List[sqlmeta.comparison.diff_models.ExtensionDiff]

missing_events

Events in expected but not in actual

Type:

List[str]

extra_events

Events in actual but not in expected

Type:

List[str]

modified_events

Events with differences

Type:

List[sqlmeta.comparison.diff_models.EventDiff]

missing_user_defined_types

User-defined types in expected but not in actual

Type:

List[str]

extra_user_defined_types

User-defined types in actual but not in expected

Type:

List[str]

modified_user_defined_types

User-defined types with differences

Type:

List[sqlmeta.comparison.diff_models.UserDefinedTypeDiff]

__init__(object_name: str, object_type: str = '', severity: ~sqlmeta.comparison.diff_models.DiffSeverity = DiffSeverity.INFO, has_diffs: bool = False, schema_name: str = '', missing_tables: ~typing.List[str] = <factory>, extra_tables: ~typing.List[str] = <factory>, modified_tables: ~typing.List[~sqlmeta.comparison.diff_models.TableDiff] = <factory>, missing_views: ~typing.List[str] = <factory>, extra_views: ~typing.List[str] = <factory>, modified_views: ~typing.List[~sqlmeta.comparison.diff_models.ViewDiff] = <factory>, missing_indexes: ~typing.List[str] = <factory>, extra_indexes: ~typing.List[str] = <factory>, modified_indexes: ~typing.List[~sqlmeta.comparison.diff_models.IndexDiff] = <factory>, missing_sequences: ~typing.List[str] = <factory>, extra_sequences: ~typing.List[str] = <factory>, modified_sequences: ~typing.List[~sqlmeta.comparison.diff_models.SequenceDiff] = <factory>, missing_triggers: ~typing.List[str] = <factory>, extra_triggers: ~typing.List[str] = <factory>, modified_triggers: ~typing.List[~sqlmeta.comparison.diff_models.TriggerDiff] = <factory>, missing_procedures: ~typing.List[str] = <factory>, extra_procedures: ~typing.List[str] = <factory>, modified_procedures: ~typing.List[~sqlmeta.comparison.diff_models.ProcedureDiff] = <factory>, missing_functions: ~typing.List[str] = <factory>, extra_functions: ~typing.List[str] = <factory>, modified_functions: ~typing.List[~sqlmeta.comparison.diff_models.FunctionDiff] = <factory>, missing_synonyms: ~typing.List[str] = <factory>, extra_synonyms: ~typing.List[str] = <factory>, modified_synonyms: ~typing.List[~sqlmeta.comparison.diff_models.SynonymDiff] = <factory>, missing_packages: ~typing.List[str] = <factory>, extra_packages: ~typing.List[str] = <factory>, modified_packages: ~typing.List[~sqlmeta.comparison.diff_models.PackageDiff] = <factory>, missing_modules: ~typing.List[str] = <factory>, extra_modules: ~typing.List[str] = <factory>, modified_modules: ~typing.List[~sqlmeta.comparison.diff_models.ModuleDiff] = <factory>, missing_database_links: ~typing.List[str] = <factory>, extra_database_links: ~typing.List[str] = <factory>, modified_database_links: ~typing.List[~sqlmeta.comparison.diff_models.DatabaseLinkDiff] = <factory>, missing_linked_servers: ~typing.List[str] = <factory>, extra_linked_servers: ~typing.List[str] = <factory>, modified_linked_servers: ~typing.List[~sqlmeta.comparison.diff_models.LinkedServerDiff] = <factory>, missing_foreign_data_wrappers: ~typing.List[str] = <factory>, extra_foreign_data_wrappers: ~typing.List[str] = <factory>, modified_foreign_data_wrappers: ~typing.List[~sqlmeta.comparison.diff_models.ForeignDataWrapperDiff] = <factory>, missing_foreign_servers: ~typing.List[str] = <factory>, extra_foreign_servers: ~typing.List[str] = <factory>, modified_foreign_servers: ~typing.List[~sqlmeta.comparison.diff_models.ForeignServerDiff] = <factory>, missing_extensions: ~typing.List[str] = <factory>, extra_extensions: ~typing.List[str] = <factory>, modified_extensions: ~typing.List[~sqlmeta.comparison.diff_models.ExtensionDiff] = <factory>, missing_events: ~typing.List[str] = <factory>, extra_events: ~typing.List[str] = <factory>, modified_events: ~typing.List[~sqlmeta.comparison.diff_models.EventDiff] = <factory>, missing_user_defined_types: ~typing.List[str] = <factory>, extra_user_defined_types: ~typing.List[str] = <factory>, modified_user_defined_types: ~typing.List[~sqlmeta.comparison.diff_models.UserDefinedTypeDiff] = <factory>) None
__post_init__()[source]

Calculate has_diffs and severity after initialization.

__str__() str[source]

Human-readable string representation.

get_diff_count() Dict[str, int][source]

Get count of each type of difference.

Returns:

Dictionary with counts of different types

get_total_diff_count() int[source]

Get total count of all differences.

Returns:

Total number of differences

schema_name: str = ''
to_dict() Dict[str, Any][source]

Convert to dictionary for serialization.

missing_tables: List[str]
extra_tables: List[str]
modified_tables: List[TableDiff]
missing_views: List[str]
extra_views: List[str]
modified_views: List[ViewDiff]
missing_indexes: List[str]
extra_indexes: List[str]
modified_indexes: List[IndexDiff]
missing_sequences: List[str]
extra_sequences: List[str]
modified_sequences: List[SequenceDiff]
missing_triggers: List[str]
extra_triggers: List[str]
modified_triggers: List[TriggerDiff]
missing_procedures: List[str]
extra_procedures: List[str]
modified_procedures: List[ProcedureDiff]
missing_functions: List[str]
extra_functions: List[str]
modified_functions: List[FunctionDiff]
missing_synonyms: List[str]
extra_synonyms: List[str]
modified_synonyms: List[SynonymDiff]
missing_packages: List[str]
extra_packages: List[str]
modified_packages: List[PackageDiff]
missing_modules: List[str]
extra_modules: List[str]
modified_modules: List[ModuleDiff]
missing_linked_servers: List[str]
extra_linked_servers: List[str]
modified_linked_servers: List[LinkedServerDiff]
missing_foreign_data_wrappers: List[str]
extra_foreign_data_wrappers: List[str]
modified_foreign_data_wrappers: List[ForeignDataWrapperDiff]
missing_foreign_servers: List[str]
extra_foreign_servers: List[str]
modified_foreign_servers: List[ForeignServerDiff]
missing_extensions: List[str]
extra_extensions: List[str]
modified_extensions: List[ExtensionDiff]
missing_events: List[str]
extra_events: List[str]
modified_events: List[EventDiff]
missing_user_defined_types: List[str]
extra_user_defined_types: List[str]
modified_user_defined_types: List[UserDefinedTypeDiff]

Modules

comparator

SQL Object Comparator for Drift Detection.

diff_models

Diff Models for SQL Object Comparison Results.

type_normalizer

Data Type Normalization for Cross-Dialect Comparison.