@@ -490,40 +490,42 @@ jobs:
490490 "\t\t);"
491491 )
492492 assert old in src, 'sync_column_key_info UPDATE not found'
493- new = ''' $columns_table = $this->connection->quote_identifier( $columns_table_name );
494- $statistics_table = $this->connection->quote_identifier( $statistics_table_name );
495- $this->connection->query(
496- "
497- UPDATE $columns_table AS c
498- SET column_key = (
499- SELECT
500- CASE
501- WHEN MAX(s.index_name = 'PRIMARY') THEN 'PRI'
502- WHEN MAX(s.non_unique = 0 AND s.seq_in_index = 1) THEN 'UNI'
503- WHEN MAX(s.seq_in_index = 1) THEN 'MUL'
504- ELSE ''
505- END
506- FROM $statistics_table AS s
507- WHERE s.table_schema = c.table_schema
508- AND s.table_name = c.table_name
509- AND s.column_name = c.column_name
510- ),
511- is_nullable = (
512- SELECT
513- CASE
514- WHEN MAX(s.index_name = 'PRIMARY') THEN 'NO'
515- ELSE c.is_nullable
516- END
517- FROM $statistics_table AS s
518- WHERE s.table_schema = c.table_schema
519- AND s.table_name = c.table_name
520- AND s.column_name = c.column_name
521- )
522- WHERE c.table_schema = ?
523- AND c.table_name = ?
524- ",
525- array( self::SAVED_DATABASE_NAME, $table_name )
526- );'''
493+ new = "\n".join([
494+ "\t\t$columns_table = $this->connection->quote_identifier( $columns_table_name );",
495+ "\t\t$statistics_table = $this->connection->quote_identifier( $statistics_table_name );",
496+ "\t\t$this->connection->query(",
497+ "\t\t\t\"",
498+ "\t\t\t\tUPDATE $columns_table AS c",
499+ "\t\t\t\tSET column_key = (",
500+ "\t\t\t\t\tSELECT",
501+ "\t\t\t\t\t\tCASE",
502+ "\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'PRI'",
503+ "\t\t\t\t\t\t\tWHEN MAX(s.non_unique = 0 AND s.seq_in_index = 1) THEN 'UNI'",
504+ "\t\t\t\t\t\t\tWHEN MAX(s.seq_in_index = 1) THEN 'MUL'",
505+ "\t\t\t\t\t\t\tELSE ''",
506+ "\t\t\t\t\t\tEND",
507+ "\t\t\t\t\tFROM $statistics_table AS s",
508+ "\t\t\t\t\tWHERE s.table_schema = c.table_schema",
509+ "\t\t\t\t\tAND s.table_name = c.table_name",
510+ "\t\t\t\t\tAND s.column_name = c.column_name",
511+ "\t\t\t\t),",
512+ "\t\t\t\tis_nullable = (",
513+ "\t\t\t\t\tSELECT",
514+ "\t\t\t\t\t\tCASE",
515+ "\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'NO'",
516+ "\t\t\t\t\t\t\tELSE c.is_nullable",
517+ "\t\t\t\t\t\tEND",
518+ "\t\t\t\t\tFROM $statistics_table AS s",
519+ "\t\t\t\t\tWHERE s.table_schema = c.table_schema",
520+ "\t\t\t\t\tAND s.table_name = c.table_name",
521+ "\t\t\t\t\tAND s.column_name = c.column_name",
522+ "\t\t\t\t)",
523+ "\t\t\t\tWHERE c.table_schema = ?",
524+ "\t\t\t\tAND c.table_name = ?",
525+ "\t\t\t\",",
526+ "\t\t\tarray( self::SAVED_DATABASE_NAME, $table_name )",
527+ "\t\t);",
528+ ])
527529 src = src.replace(old, new, 1)
528530 open(path, 'w').write(src)
529531 print('patched information-schema-builder.php')
0 commit comments