launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03592
[Merge] lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad
Stuart Bishop has proposed merging lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #179821 in Launchpad itself: "Case sensitive table names are not to be used"
https://bugs.launchpad.net/launchpad/+bug/179821
For more details, see:
https://code.launchpad.net/~stub/launchpad/bug-179821-lowercase-tablenames/+merge/60640
--
https://code.launchpad.net/~stub/launchpad/bug-179821-lowercase-tablenames/+merge/60640
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad.
=== modified file 'lib/canonical/database/ftests/test_multitablecopy.txt'
--- lib/canonical/database/ftests/test_multitablecopy.txt 2010-10-18 22:24:59 +0000
+++ lib/canonical/database/ftests/test_multitablecopy.txt 2011-05-11 14:56:42 +0000
@@ -39,6 +39,18 @@
>>> copier = MultiTableCopy('test', ['numeric', 'textual'],
... seconds_per_batch=0.1, minimum_batch_size=1)
+Note that the copier will not let us create tables with mixed case names.
+
+ >>> copier.getRawHoldingTableName('Foo')
+ Traceback (most recent call last):
+ ...
+ AssertionError: Unsupported characters in table name per Bug #179821
+
+ >>> copier.getRawHoldingTableName('foo', '-bar')
+ Traceback (most recent call last):
+ ...
+ AssertionError: Unsupported characters in table name per Bug #179821
+
=== Ordering ===
=== modified file 'lib/canonical/database/multitablecopy.py'
--- lib/canonical/database/multitablecopy.py 2009-06-25 05:30:52 +0000
+++ lib/canonical/database/multitablecopy.py 2011-05-11 14:56:42 +0000
@@ -3,9 +3,10 @@
__metaclass__ = type
-__all__ = [ 'MultiTableCopy' ]
+__all__ = ['MultiTableCopy']
import logging
+import re
import time
from zope.interface import implements
@@ -110,6 +111,7 @@
self.batch_pouring_callback(
from_table, to_table, batch_size, begin_id, end_id)
+
class MultiTableCopy:
"""Copy interlinked data spanning multiple tables in a coherent fashion.
@@ -253,9 +255,15 @@
"""Name for a holding table, but without quotes. Use with care."""
if suffix:
suffix = '_%s' % suffix
- return "temp_%s_holding_%s%s" % (
+
+ assert re.search(r'[^a-z_]', tablename + suffix) is None, (
+ 'Unsupported characters in table name per Bug #179821')
+
+ raw_name = "temp_%s_holding_%s%s" % (
str(tablename), self.name, str(suffix))
+ return raw_name
+
def getHoldingTableName(self, tablename, suffix=''):
"""Name for a holding table to hold data being copied in tablename.
@@ -371,7 +379,7 @@
holding_table = self.getHoldingTableName(source_table)
self.logger.info('Extracting from %s into %s...' % (
- source_table,holding_table))
+ source_table, holding_table))
starttime = time.time()
@@ -385,7 +393,7 @@
self._indexIdColumn(holding_table, source_table, cur)
self.logger.debug(
- '...Extracted in %.3f seconds' % (time.time()-starttime))
+ '...Extracted in %.3f seconds' % (time.time() - starttime))
def _selectToHolding(self, source_table, joins, external_joins,
where_clause, holding_table, id_sequence, inert_where):
@@ -587,7 +595,7 @@
self.logger.debug(
"Pouring %s took %.3f seconds."
- % (holding_table, time.time()-tablestarttime))
+ % (holding_table, time.time() - tablestarttime))
cur = self._commit(transaction_manager)
@@ -651,7 +659,7 @@
if table_number < self.last_extracted_table:
raise AssertionError(
"Table '%s' extracted after its turn" % source_table)
- if table_number > self.last_extracted_table+1:
+ if table_number > self.last_extracted_table + 1:
raise AssertionError(
"Table '%s' extracted before its turn" % source_table)
if table_number == self.last_extracted_table:
@@ -696,4 +704,3 @@
self.logger.debug("Committed in %.3f seconds" % (time.time() - start))
transaction_manager.begin()
return cursor()
-