From 33d2940b1bd9889ab7b041d7de75280ec978e180 Mon Sep 17 00:00:00 2001 From: Epithumia Date: Thu, 19 Dec 2013 13:03:48 +0100 Subject: [PATCH] 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 --- pokedex/db/__init__.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pokedex/db/__init__.py b/pokedex/db/__init__.py index 37548fc..6a191d1 100644 --- a/pokedex/db/__init__.py +++ b/pokedex/db/__init__.py @@ -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