@@ -255,35 +255,27 @@ def get_columns(self, conn, table_name, schema=None, **kw):
255255 return res
256256
257257 def get_indexes (self , conn , table_name , schema = None , ** kw ):
258+ if self ._is_v192plus :
259+ return super ().get_indexes (conn , table_name , schema , ** kw )
260+
258261 # The Cockroach database creates a UNIQUE INDEX implicitly whenever the
259262 # UNIQUE CONSTRAINT construct is used. Currently we are just ignoring all unique indexes,
260263 # but we might need to return them and add an additional key `duplicates_constraint` if
261264 # it is detected as mirroring a constraint.
262265 # https://www.cockroachlabs.com/docs/stable/unique.html
263266 # https://github.com/sqlalchemy/sqlalchemy/blob/55f930ef3d4e60bed02a2dad16e331fe42cfd12b/lib/sqlalchemy/dialects/postgresql/base.py#L723
264- if not self ._is_v2plus :
265- q = '''
266- SELECT
267- "Name" as index_name,
268- "Column" as column_name,
269- "Unique" as unique,
270- "Implicit" as implicit
271- FROM
272- [SHOW INDEXES FROM "%(schema)s"."%(name)s"]
273- '''
274- else :
275- q = '''
276- SELECT
277- index_name,
278- column_name,
279- (not non_unique::bool) as unique,
280- implicit::bool as implicit
281- FROM
282- information_schema.statistics
283- WHERE
284- table_schema = %(schema)s
285- AND table_name = %(name)s
286- '''
267+ q = '''
268+ SELECT
269+ index_name,
270+ column_name,
271+ (not non_unique::bool) as unique,
272+ implicit::bool as implicit
273+ FROM
274+ information_schema.statistics
275+ WHERE
276+ table_schema = %(schema)s
277+ AND table_name = %(name)s
278+ '''
287279 rows = conn .execute (q , schema = (schema or self .default_schema_name ), name = table_name )
288280 indexes = collections .defaultdict (list )
289281 for row in rows :
0 commit comments