@@ -319,21 +319,17 @@ def get_check_constraints(self, connection, table_name, schema, **kw):
319
319
320
320
@reflection .cache
321
321
def _get_schema_primary_keys (self , connection , schema , table_name = None , ** kw ):
322
- if table_name is not None :
323
- fully_qualified_path = self ._denormalize_quote_join (
324
- schema , self .denormalize_name (table_name )
325
- )
326
- result = connection .execute (
327
- text (
328
- f"SHOW /* sqlalchemy:_get_schema_primary_keys */ PRIMARY KEYS IN TABLE { fully_qualified_path } "
329
- )
330
- )
331
- else :
332
- result = connection .execute (
333
- text (
334
- f"SHOW /* sqlalchemy:_get_schema_primary_keys */PRIMARY KEYS IN SCHEMA { schema } "
335
- )
322
+ fully_qualified_path = (
323
+ self ._denormalize_quote_join (schema , self .denormalize_name (table_name ))
324
+ if table_name is not None
325
+ else schema
326
+ )
327
+ result = connection .execute (
328
+ text (
329
+ f"SHOW /* sqlalchemy:_get_schema_primary_keys */ PRIMARY KEYS IN "
330
+ f"{ 'TABLE' if table_name is not None else 'SCHEMA' } { fully_qualified_path } "
336
331
)
332
+ )
337
333
ans = {}
338
334
for row in result :
339
335
table_name = self .normalize_name (row ._mapping ["table_name" ])
@@ -364,19 +360,17 @@ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
364
360
365
361
@reflection .cache
366
362
def _get_schema_unique_constraints (self , connection , schema , table_name = None , ** kw ):
367
- if table_name is not None :
368
- fully_qualified_path = self ._denormalize_quote_join (schema , table_name )
369
- result = connection .execute (
370
- text (
371
- f"SHOW /* sqlalchemy:_get_schema_unique_constraints */ UNIQUE KEYS IN TABLE { fully_qualified_path } "
372
- )
373
- )
374
- else :
375
- result = connection .execute (
376
- text (
377
- f"SHOW /* sqlalchemy:_get_schema_unique_constraints */ UNIQUE KEYS IN SCHEMA { schema } "
378
- )
363
+ fully_qualified_path = (
364
+ self ._denormalize_quote_join (schema , self .denormalize_name (table_name ))
365
+ if table_name is not None
366
+ else schema
367
+ )
368
+ result = connection .execute (
369
+ text (
370
+ f"SHOW /* sqlalchemy:_get_schema_unique_constraints */ UNIQUE KEYS IN "
371
+ f"{ 'TABLE' if table_name is not None else 'SCHEMA' } { fully_qualified_path } "
379
372
)
373
+ )
380
374
unique_constraints = {}
381
375
for row in result :
382
376
name = self .normalize_name (row ._mapping ["constraint_name" ])
@@ -415,21 +409,17 @@ def get_unique_constraints(self, connection, table_name, schema, **kw):
415
409
@reflection .cache
416
410
def _get_schema_foreign_keys (self , connection , schema , table_name = None , ** kw ):
417
411
_ , current_schema = self ._current_database_schema (connection , ** kw )
418
- if table_name is not None :
419
- fully_qualified_path = self ._denormalize_quote_join (
420
- schema , self .denormalize_name (table_name )
421
- )
422
- result = connection .execute (
423
- text (
424
- f"SHOW /* sqlalchemy:_get_schema_foreign_keys */ IMPORTED KEYS IN TABLE { fully_qualified_path } "
425
- )
426
- )
427
- else :
428
- result = connection .execute (
429
- text (
430
- f"SHOW /* sqlalchemy:_get_schema_foreign_keys */ IMPORTED KEYS IN SCHEMA { schema } "
431
- )
412
+ fully_qualified_path = (
413
+ self ._denormalize_quote_join (schema , self .denormalize_name (table_name ))
414
+ if table_name is not None
415
+ else schema
416
+ )
417
+ result = connection .execute (
418
+ text (
419
+ f"SHOW /* sqlalchemy:_get_schema_foreign_keys */ IMPORTED KEYS IN "
420
+ f"{ 'TABLE' if table_name is not None else 'SCHEMA' } { fully_qualified_path } "
432
421
)
422
+ )
433
423
foreign_key_map = {}
434
424
for row in result :
435
425
name = self .normalize_name (row ._mapping ["fk_name" ])
@@ -711,14 +701,7 @@ def get_columns(self, connection, table_name, schema=None, **kw):
711
701
if not schema :
712
702
_ , schema = self ._current_database_schema (connection , ** kw )
713
703
714
- if table_name is not None :
715
- return self ._get_table_columns (connection , table_name , schema , ** kw )
716
- else :
717
- schema_columns = self ._get_schema_columns (connection , schema , ** kw )
718
- if schema_columns is None :
719
- # Too many results, fall back to only query about single table
720
- return self ._get_table_columns (connection , table_name , schema , ** kw )
721
- return schema_columns [self .normalize_name (table_name )]
704
+ return self ._get_table_columns (connection , table_name , schema , ** kw )
722
705
723
706
@reflection .cache
724
707
def get_table_names (self , connection , schema = None , ** kw ):
0 commit comments