:param diff: The table diff
        :type diff: orator.dbal.table_diff.TableDiff

        :rtype: dict
354253
def _get_primary_index_in_altered_table(self, diff):
        
        primary_index = {}

        for index in self._get_indexes_in_altered_table(diff).values():
            if index.is_primary():
                primary_index = {index.get_name(): index}

        return primary_index
1308977
def _get_foreign_keys_in_altered_table(self, diff):
        
        foreign_keys = diff.from_table.get_foreign_keys()
        column_names = self._get_column_names_in_altered_table(diff)

        for key, constraint in foreign_keys.items():
            changed = False
            local_columns = []
            for column_name in constraint.get_local_columns():
                normalized_column_name = column_name.lower()
                if normalized_column_name not in column_names:
                    del foreign_keys[key]
                    break
                else:
                    local_columns.append(column_names[normalized_column_name])
                    if column_name != column_names[normalized_column_name]:
                        changed = True

            if changed:
                foreign_keys[key] = ForeignKeyConstraint(
                    local_columns,
                    constraint.get_foreign_table_name(),
                    constraint.get_foreign_columns(),
                    constraint.get_name(),
                    constraint.get_options(),
                )

        for constraint in diff.removed_foreign_keys:
            constraint_name = constraint.get_name().lower()
            if constraint_name and constraint_name in foreign_keys:
                del foreign_keys[constraint_name]

        foreign_keys_diff = diff.changed_foreign_keys + diff.added_foreign_keys
        for constraint in foreign_keys_diff:
            constraint_name = constraint.get_name().lower()
            if constraint_name:
                foreign_keys[constraint_name] = constraint
            else:
                foreign_keys[len(foreign_keys)] = constraint

        return foreign_keys
1370407
def _get_values(cls, diff_dict, type='new'):
        '''
        
        '''
        ret_dict = {}
        for p in diff_dict.keys():
            if type in diff_dict[p].keys():
                ret_dict.update({p: diff_dict[p][type]})
            else:
                ret_dict.update(
                    {p: cls._get_values(diff_dict[p], type=type)})
        return ret_dict
6695
def print_diff(self, ignore=[]):
        
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        diff = self.get_diff(ignore)
        print("Added objects:")
        summary.print_(summary.summarize(diff['+']))
        print("Removed objects:")
        summary.print_(summary.summarize(diff['-']))
        # manual cleanup, see comment above
        del ignore[:]
508860
def diff(self, other):
        
        diff = {}
        for k in self.__class__.defaults:
            left = getattr(self, k)
            right = getattr(other, k)
            if left != right:
                diff[k] = (left, right)
        return diff
763118
def idfdiffs(idf1, idf2):
    """"""
    # for any object type, it is sorted by name
    thediffs = {}
    keys = idf1.model.dtls # undocumented variable

    for akey in keys:
        idfobjs1 = idf1.idfobjects[akey]
        idfobjs2 = idf2.idfobjects[akey]
        names = set([getobjname(i) for i in idfobjs1] +
                    [getobjname(i) for i in idfobjs2])
        names = sorted(names)
        idfobjs1 = sorted(idfobjs1, key=lambda idfobj: idfobj['obj'])
        idfobjs2 = sorted(idfobjs2, key=lambda idfobj: idfobj['obj'])
        for name in names:
            n_idfobjs1 = [item for item in idfobjs1
                          if getobjname(item) == name]
            n_idfobjs2 = [item for item in idfobjs2
                          if getobjname(item) == name]
            for idfobj1, idfobj2 in zip_longest(n_idfobjs1,
                                                           n_idfobjs2):
                if idfobj1 == None:
                    thediffs[(idfobj2.key.upper(), 
                                getobjname(idfobj2))] = (None, idf2.idfname) #(idf1.idfname, None) -> old
                    break
                if idfobj2 == None:
                    thediffs[(idfobj1.key.upper(), 
                                getobjname(idfobj1))] = (idf1.idfname, None) # (None, idf2.idfname) -> old
                    break
                for i, (f1, f2) in enumerate(zip(idfobj1.obj, idfobj2.obj)):
                    if i == 0:
                        f1, f2 = f1.upper(), f2.upper()
                    if f1 != f2:
                        thediffs[(
                            akey,
                            getobjname(idfobj1),
                            idfobj1.objidd[i]['field'][0])] = (f1, f2)
    return thediffs
306170
def diff_table(self, table1, table2):
        
        changes = 0
        table_differences = TableDiff(table1.get_name())
        table_differences.from_table = table1

        table1_columns = table1.get_columns()
        table2_columns = table2.get_columns()

        # See if all the fields in table1 exist in table2
        for column_name, column in table2_columns.items():
            if not table1.has_column(column_name):
                table_differences.added_columns[column_name] = column
                changes += 1

        # See if there are any removed fields in table2
        for column_name, column in table1_columns.items():
            if not table2.has_column(column_name):
                table_differences.removed_columns[column_name] = column
                changes += 1
                continue

            # See if column has changed properties in table2
            changed_properties = self.diff_column(column, table2.get_column(column_name))

            if changed_properties:
                column_diff = ColumnDiff(column.get_name(),
                                         table2.get_column(column_name),
                                         changed_properties)
                column_diff.from_column = column
                table_differences.changed_columns[column.get_name()] = column_diff
                changes += 1

        self.detect_column_renamings(table_differences)

        # table1_indexes = table1.get_indexes()
        # table2_indexes = table2.get_indexes()
        #
        # # See if all the fields in table1 exist in table2
        # for index_name, index in table2_indexes.items():
        #     if (index.is_primary() and table1.has_primary_key()) or table1.has_index(index_name):
        #         continue
        #
        #     table_differences.added_indexes[index_name] = index
        #     changes += 1
        #
        # # See if there are any removed fields in table2
        # for index_name, index in table1_indexes.items():
        #     if (index.is_primary() and not table2.has_primary_key())\
        #             or (not index.is_primary() and not table2.has_index(index_name)):
        #         table_differences.removed_indexes[index_name] = index
        #         changes += 1
        #         continue
        #
        #     if index.is_primary():
        #         table2_index = table2.get_primary_key()
        #     else:
        #         table2_index = table2.get_index(index_name)
        #
        #     if self.diff_index(index, table2_index):
        #         table_differences.changed_indexes[index_name] = index
        #         changes += 1
        #
        # self.detect_index_renamings(table_differences)
        #
        # from_fkeys = table1.get_foreign_keys()
        # to_fkeys = table2.get_foreign_keys()
        #
        # for key1, constraint1 in from_fkeys.items():
        #     for key2, constraint2 in to_fkeys.items():
        #         if self.diff_foreign_key(constraint1, constraint2) is False:
        #             del from_fkeys[key1]
        #             del to_fkeys[key2]
        #         else:
        #             if constraint1.get_name().lower() == constraint2.get_name().lower():
        #                 table_differences.changed_foreign_keys.append(constraint2)
        #                 changes += 1
        #                 del from_fkeys[key1]
        #                 del to_fkeys[key2]
        #
        # for constraint1 in from_fkeys.values():
        #     table_differences.removed_foreign_keys.append(constraint1)
        #     changes += 1
        #
        # for constraint2 in to_fkeys.values():
        #     table_differences.added_foreign_keys.append(constraint2)
        #     changes += 1

        if changes:
            return table_differences

        return False
974427
def get_diff(self, new_mapping):
        
        import copy
        result = copy.deepcopy(new_mapping)
        result.clear_properties()

        no_check_types = (BooleanField, IntegerField, FloatField, DateField, LongField, BinaryField,
                          GeoPointField, IpField)

        old_fields = set(self.properties.keys())
        new_fields = set(new_mapping.properties.keys())
        #we propagate new fields
        added = new_fields - old_fields
        if added:
            for add in added:
                result.add_property(new_mapping.properties[add])

        #we check common fields
        common_fields = new_fields & old_fields

        #removing standard data
        common_fields = [c for c in common_fields if not isinstance(new_mapping.properties[c], no_check_types)]

        for field in common_fields:
            prop = new_mapping.properties[field]
            if isinstance(prop, StringField):
                continue
            if isinstance(prop, MultiField):
                diff = prop.get_diff(self.properties[field])
                if diff:
                    result.add_property(diff)
            elif isinstance(prop, ObjectField):
                diff = self.properties[field].get_diff(prop)
                if diff:
                    result.add_property(diff)

        if len(result.properties) > 0:
            return result
        return None
512525
def diff(self, other, **kwargs):
        
        from normalize.diff import diff
        return diff(self, other, **kwargs)
871021
def deep_diff(self, db_data, user_data):
        
        # NOTE: tcex does include the deepdiff library as a dependencies since it is only
        # required for local testing.
        try:
            from deepdiff import DeepDiff
        except ImportError:
            print('Could not import DeepDiff module (try "pip install deepdiff").')
            sys.exit(1)

        try:
            ddiff = DeepDiff(db_data, user_data, ignore_order=True)
        except KeyError:
            return False
        except NameError:
            return False
        if ddiff:
            self.tcex.log.info(u'[validate] Diff      : {}'.format(ddiff))
            return False
        return True
1264296
def remove_diff(self, diff_key=None, diff_list='intersect'):
        ''''''
        if diff_list == 'intersect':
            for item in self._intersect:
                item['old'].pop(diff_key, None)
                item['new'].pop(diff_key, None)
        if diff_list == 'removed':
            for item in self._removed:
                item.pop(diff_key, None)
415922
def _set_renamed_columns(self, table_diff, command, column):
        
        new_column = Column(command.to, column.get_type(), column.to_dict())

        table_diff.renamed_columns = {command.from_: new_column}

        return table_diff
329626
def get_diff(a, b, *args, **kwargs):
    '''
    
    '''
    encoding = ('utf-8', 'latin-1', __salt_system_encoding__)
    # Late import to avoid circular import
    import salt.utils.data
    return ''.join(
        difflib.unified_diff(
            salt.utils.data.decode_list(a, encoding=encoding),
            salt.utils.data.decode_list(b, encoding=encoding),
            *args, **kwargs
        )
    )
236063
public static ns_config_diff diff_table(nitro_service client, ns_config_diff resource) throws Exception
	{
		return ((ns_config_diff[]) resource.perform_operation(client, "diff_table"))[0];
	}
259336
def get_alter_table_sql(self, diff):
        
        #sql = self._get_simple_alter_table_sql(diff)

        from_table = diff.from_table
        if not isinstance(from_table, Table):
            raise Exception('SQLite platform requires for the alter table the table diff '
                            'referencing the original table')

        table = from_table.clone()
        columns = {}
        old_column_names = {}
        new_column_names = {}
        column_sql = []
        for column_name, column in table.get_columns().items():
            column_name = column_name.lower()
            columns[column_name] = column
            old_column_names[column_name] = column.get_name()
            new_column_names[column_name] = column.get_name()

        for column_name, column in diff.removed_columns.items():
            column_name = column_name.lower()
            if column_name in columns:
                del columns[column_name]
                del old_column_names[column_name]
                del new_column_names[column_name]

        for old_column_name, column in diff.renamed_columns.items():
            old_column_name = old_column_name.lower()
            if old_column_name in columns:
                del columns[old_column_name]

            columns[column.get_name().lower()] = column

            if old_column_name in new_column_names:
                new_column_names[old_column_name] = column.get_name()

        for old_column_name, column_diff in diff.changed_columns.items():
            if old_column_name in columns:
                del columns[old_column_name]

            columns[column_diff.column.get_name().lower()] = column_diff.column

            if old_column_name in new_column_names:
                new_column_names[old_column_name] = column_diff.column.get_name()

        for column_name, column in diff.added_columns.items():
            columns[column_name.lower()] = column

        sql = []
        table_sql = []

        data_table = Table('__temp__' + table.get_name())

        new_table = Table(table.get_name(), columns,
                          self.get_primary_index_in_altered_table(diff),
                          self.get_foreign_keys_in_altered_table(diff))
        new_table.add_option('alter', True)

        sql = self.get_pre_alter_table_index_foreign_key_sql(diff)
        sql.append('CREATE TEMPORARY TABLE %s AS SELECT %s FROM %s'
                   % (data_table.get_name(), ', '.join(old_column_names.values()), table.get_name()))
        sql.append(self.get_drop_table_sql(from_table))

        sql += self.get_create_table_sql(new_table)
        sql.append('INSERT INTO %s (%s) SELECT %s FROM %s'
                   % (new_table.get_name(),
                      ', '.join(new_column_names.values()),
                      ', '.join(old_column_names.values()),
                      data_table.get_name()))
        sql.append(self.get_drop_table_sql(data_table))

        sql += self.get_post_alter_table_index_foreign_key_sql(diff)

        return sql
1292450
def diffs(options = {})
      if parents.empty?
        show
      else
        self.class.diff(@repo, parents.first.id, @id, [], options)
      end
    end
983605
def get_alter_table_sql(self, diff):
        
        column_sql = []
        query_parts = []

        if diff.new_name is not False:
            query_parts.append('RENAME TO %s' % diff.new_name)

        # Added columns?

        # Removed columns?

        for column_diff in diff.changed_columns.values():
            column = column_diff.column
            column_dict = column.to_dict()

            # Don't propagate default value changes for unsupported column types.
            if column_diff.has_changed('default') \
                    and len(column_diff.changed_properties) == 1 \
                    and (column_dict['type'] == 'text' or column_dict['type'] == 'blob'):
                continue

            query_parts.append('CHANGE %s %s'
                               % (column_diff.get_old_column_name(),
                                  self.get_column_declaration_sql(column.get_name(), column_dict)))

        for old_column_name, column in diff.renamed_columns.items():
            column_dict = column.to_dict()
            query_parts.append('CHANGE %s %s'
                               % (self.quote(old_column_name),
                                  self.get_column_declaration_sql(self.quote(column.get_name()), column_dict)))

        sql = []

        if len(query_parts) > 0:
            sql.append('ALTER TABLE %s %s' % (diff.name, ', '.join(query_parts)))

        return sql