Group the oracle-related renaming into functions in oracle.py ; check whether a renaming was already done before doing it, likewise check if a renaming was done before undoing it

This commit is contained in:
Epithumia 2013-12-19 13:03:48 +01:00
parent 6724e301be
commit 33d2940b1b

View file

@ -6,6 +6,7 @@ from sqlalchemy import engine_from_config, orm
from ..defaults import get_default_db_uri
from .tables import Language, metadata
from .multilang import MultilangSession, MultilangScopedSession
from .oracle import rewrite_long_table_names, restore_long_table_names
ENGLISH_ID = 9
@ -48,15 +49,10 @@ def connect(uri=None, session_args={}, engine_args={}, engine_prefix=''):
# Shorten table names, Oracle limits table and column names to 30 chars
# Easy solution : drop the vowels, differents words are unlikely to
# end up the same after the vowels are gone
try:
# Check we haven't already shortened the names
metadata.tables.values()[1]._original_name
except NameError:
for table in metadata.tables.values():
table._orginal_name = table.name[:]
if len(table.name) > 30:
for letter in ['a', 'e', 'i', 'o', 'u', 'y']:
table.name=table.name.replace(letter,'')
rewrite_long_table_names(metadata.tables)
else:
restore_long_table_names(metadata.tables)
### Connect