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 ..defaults import get_default_db_uri
|
||||||
from .tables import Language, metadata
|
from .tables import Language, metadata
|
||||||
from .multilang import MultilangSession, MultilangScopedSession
|
from .multilang import MultilangSession, MultilangScopedSession
|
||||||
|
from .oracle import rewrite_long_table_names, restore_long_table_names
|
||||||
|
|
||||||
ENGLISH_ID = 9
|
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
|
# Shorten table names, Oracle limits table and column names to 30 chars
|
||||||
# Easy solution : drop the vowels, differents words are unlikely to
|
# Easy solution : drop the vowels, differents words are unlikely to
|
||||||
# end up the same after the vowels are gone
|
# end up the same after the vowels are gone
|
||||||
try:
|
rewrite_long_table_names(metadata.tables)
|
||||||
# Check we haven't already shortened the names
|
else:
|
||||||
metadata.tables.values()[1]._original_name
|
restore_long_table_names(metadata.tables)
|
||||||
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,'')
|
|
||||||
|
|
||||||
|
|
||||||
### Connect
|
### Connect
|
||||||
|
|
Loading…
Reference in a new issue