From 38f6323a5ce0a287100da66a73ed52af8cbc8f86 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 24 Mar 2003 04:47:44 +0000 Subject: [PATCH] fixed rdbms email address lookup (case insensitivity) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1621 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/backends/rdbms_common.py | 4 ++-- test/test_mailgw.py | 13 +++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f811fcb..e15788b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -82,6 +82,7 @@ Fixed: - fixed sqlite rollback/caching bug (sf bug 689383) - fixed rdbms table update detection logic (sf bug 703297) - fixed detection of bad date specs (sf bug 691439) +- fixed rdbms email address lookup (case insensitivity) 2003-02-27 0.5.6 diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index e560629..a350425 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.47 2003-03-21 04:02:13 richard Exp $ +# $Id: rdbms_common.py,v 1.48 2003-03-24 04:47:44 richard Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -1718,7 +1718,7 @@ class Class(hyperdb.Class): args.append(requirements[propname].lower()) # generate the where clause - s = ' and '.join(['_%s=%s'%(col, self.db.arg) for col in where]) + s = ' and '.join(['lower(_%s)=%s'%(col, self.db.arg) for col in where]) sql = 'select id from _%s where %s'%(self.classname, s) self.db.sql(sql, tuple(args)) l = [x[0] for x in self.db.sql_fetchall()] diff --git a/test/test_mailgw.py b/test/test_mailgw.py index cfcd82f..0b96889 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,9 +8,10 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.41 2003-03-13 09:27:24 kedder Exp $ +# $Id: test_mailgw.py,v 1.42 2003-03-24 04:47:44 richard Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib +import rfc822 # Note: Should parse emails according to RFC2822 instead of performing a # literal string comparision. Parsing the messages allows the tests to work for @@ -20,7 +21,7 @@ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib #except ImportError : # import rfc822 as email -from roundup.mailgw import MailGW, Unauthorized +from roundup.mailgw import MailGW, Unauthorized, uidFromAddress from roundup import init, instance # TODO: make this output only enough equal lines for context, not all of @@ -909,6 +910,14 @@ This is a followup self.compareStrings(self.db.msg.get(messageid, 'content'), expect) + def testUserLookup(self): + i = self.db.user.create(username='user1', address='user1@foo.com') + self.assertEqual(uidFromAddress(self.db, ('', 'user1@foo.com'), 0), i) + self.assertEqual(uidFromAddress(self.db, ('', 'USER1@foo.com'), 0), i) + i = self.db.user.create(username='user2', address='USER2@foo.com') + self.assertEqual(uidFromAddress(self.db, ('', 'USER2@foo.com'), 0), i) + self.assertEqual(uidFromAddress(self.db, ('', 'user2@foo.com'), 0), i) + def suite(): l = [unittest.makeSuite(MailgwTestCase), ] -- 2.30.2