Skip to content

Commit 4ad3915

Browse files
1 parent 9de4563 commit 4ad3915

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

‎django_spanner/introspection.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ def get_relations(self, cursor, table_name):
167167
rc.UNIQUE_CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
168168
WHERE
169169
tc.TABLE_SCHEMA='@schema_name' AND tc.TABLE_NAME='@view_name'
170-
""", params=[
170+
""",
171+
params=[
171172
{"schema_name": schema_name},
172-
{"view_name": self.connection.ops.quote_name(table_name)}
173-
]
173+
{"view_name": self.connection.ops.quote_name(table_name)},
174+
],
174175
)
175176
return {
176177
column: (referred_column, referred_table)
@@ -202,10 +203,11 @@ def get_primary_key_column(self, cursor, table_name):
202203
ccu ON tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
203204
WHERE
204205
tc.TABLE_NAME=@table_name AND tc.CONSTRAINT_TYPE='PRIMARY KEY' AND tc.TABLE_SCHEMA=@schema_name
205-
""", params=[
206+
""",
207+
params=[
206208
{"schema_name": schema_name},
207-
{"table_name": self.connection.ops.quote_name(table_name)}
208-
]
209+
{"table_name": self.connection.ops.quote_name(table_name)},
210+
],
209211
)
210212
return results[0][0] if results else None
211213

@@ -227,16 +229,16 @@ def get_constraints(self, cursor, table_name):
227229

228230
# Firstly populate all available constraints and their columns.
229231
constraint_columns = cursor.run_sql_in_snapshot(
230-
'''
232+
"""
231233
SELECT
232234
CONSTRAINT_NAME, COLUMN_NAME
233235
FROM
234236
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
235-
WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''',
237+
WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""",
236238
params=[
237239
{"table": quoted_table_name},
238-
{"schema_name": schema_name}
239-
]
240+
{"schema_name": schema_name},
241+
],
240242
)
241243
for constraint, column_name in constraint_columns:
242244
if constraint not in constraints:
@@ -255,16 +257,17 @@ def get_constraints(self, cursor, table_name):
255257

256258
# Add the various constraints by type.
257259
constraint_types = cursor.run_sql_in_snapshot(
258-
'''
260+
"""
259261
SELECT
260262
CONSTRAINT_NAME, CONSTRAINT_TYPE
261263
FROM
262264
INFORMATION_SCHEMA.TABLE_CONSTRAINTS
263265
WHERE
264-
TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''', params=[
266+
TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""",
267+
params=[
265268
{"table": quoted_table_name},
266-
{"schema_name": schema_name}
267-
]
269+
{"schema_name": schema_name},
270+
],
268271
)
269272
for constraint, constraint_type in constraint_types:
270273
already_added = constraint in constraints
@@ -310,10 +313,11 @@ def get_constraints(self, cursor, table_name):
310313
idx.TABLE_NAME=@table AND idx.TABLE_SCHEMA=@schema_name
311314
ORDER BY
312315
idx_col.ORDINAL_POSITION
313-
""", params=[
316+
""",
317+
params=[
314318
{"table": quoted_table_name},
315-
{"schema_name": schema_name}
316-
]
319+
{"schema_name": schema_name},
320+
],
317321
)
318322
for (
319323
index_name,
@@ -371,10 +375,11 @@ def get_key_columns(self, cursor, table_name):
371375
rc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
372376
WHERE
373377
tc.TABLE_NAME=@table AND tc.TABLE_SCHEMA=@schema_name
374-
""", params=[
378+
""",
379+
params=[
375380
{"table": self.connection.ops.quote_name(table_name)},
376-
{"schema_name": schema_name}
377-
]
381+
{"schema_name": schema_name},
382+
],
378383
)
379384
key_columns.extend(cursor.fetchall())
380385
return key_columns

0 commit comments

Comments
 (0)