Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions schemainspect/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __str__(self):
def __ne__(self, other):
return not self == other

def is_equal(self, other, ignore_newlines=True):
return self.__eq__(other)


def quoted_identifier(identifier, schema=None, identity_arguments=None):
s = '"{}"'.format(identifier.replace('"', '""'))
Expand Down
15 changes: 13 additions & 2 deletions schemainspect/pg/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
RLSPOLICIES_QUERY = resource_text("sql/rlspolicies.sql")


def normalize_newlines(text):
return '\n'.join(text.splitlines())


class InspectedSelectable(BaseInspectedSelectable):
def has_compatible_columns(self, other):
def names_and_types(cols):
Expand Down Expand Up @@ -246,17 +250,24 @@ def create_statement(self):
def drop_statement(self):
return "drop function if exists {};".format(self.signature)

def __eq__(self, other):
def is_equal(self, other, ignore_newlines=False):
return (
self.signature == other.signature
and self.result_string == other.result_string
and self.definition == other.definition
and (
(normalize_newlines(self.definition.lower()) == normalize_newlines(other.definition.lower()))
if ignore_newlines
else (self.definition == other.definition)
)
and self.language == other.language
and self.volatility == other.volatility
and self.strictness == other.strictness
and self.security_type == other.security_type
)

def __eq__(self, other):
return self.is_equal(other, ignore_newlines=False)


class InspectedTrigger(Inspected):
def __init__(
Expand Down