mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
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:
parent
6724e301be
commit
33d2940b1b
1 changed files with 5 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue