summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/url.py
diff options
context:
space:
mode:
authorSanjana <sanjana0796@gmail.com>2019-02-28 10:16:13 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-02-28 14:34:52 -0500
commit9268c320bf6ea35696951875df518286dd79ad54 (patch)
treeb28587176a5ecd99f7bc1567027f863753f3fcd6 /lib/sqlalchemy/engine/url.py
parentdc48ac54893491c5ecd64a868883a22769376e9a (diff)
downloadsqlalchemy-9268c320bf6ea35696951875df518286dd79ad54.tar.gz
Add port comparison in __eq__() and __ne__() method to URL
Comparing two objects of :class:`.URL` using ``__eq__()`` did not take port number into consideration, two objects differing only by port number were considered equal. Port comparison is now added in ``__eq__()`` method of :class:`.URL`, objects differing by port number are now not equal. Additionally, ``__ne__()`` was not implemented for :class:`.URL` which caused unexpected result when ``!=`` was used in Python2, since there are no implied relationships among the comparison operators in Python2. Fixes: #4406 Closes: #4515 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4515 Pull-request-sha: 0f15b805f07e7fca1f82ca6c3aad98d50ea705b8 Change-Id: Iba7d224f1282dc3f4b884d1a746f2d46669f551e
Diffstat (limited to 'lib/sqlalchemy/engine/url.py')
-rw-r--r--lib/sqlalchemy/engine/url.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py
index 536e21c38..16b7c051a 100644
--- a/lib/sqlalchemy/engine/url.py
+++ b/lib/sqlalchemy/engine/url.py
@@ -120,8 +120,12 @@ class URL(object):
and self.host == other.host
and self.database == other.database
and self.query == other.query
+ and self.port == other.port
)
+ def __ne__(self, other):
+ return not self == other
+
@property
def password(self):
if self.password_original is None: