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