Browse Source

Merge pull request #4764 from nocodb/fix/symbol-not-found

fix(nocodb): symbol col.table_name not found
pull/4803/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
7bba416c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 98
      packages/nocodb/src/lib/db/sql-client/lib/mysql/mysql.queries.ts

98
packages/nocodb/src/lib/db/sql-client/lib/mysql/mysql.queries.ts

@ -222,7 +222,8 @@ AND t.table_name=?;`,
information_schema.KEY_COLUMN_USAGE AS kcu information_schema.KEY_COLUMN_USAGE AS kcu
INNER JOIN information_schema.REFERENTIAL_CONSTRAINTS AS rc ON INNER JOIN information_schema.REFERENTIAL_CONSTRAINTS AS rc ON
kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
Group by kcu.CONSTRAINT_NAME, Group by
kcu.CONSTRAINT_NAME,
kcu.TABLE_NAME, kcu.TABLE_NAME,
kcu.COLUMN_NAME, kcu.COLUMN_NAME,
kcu.POSITION_IN_UNIQUE_CONSTRAINT, kcu.POSITION_IN_UNIQUE_CONSTRAINT,
@ -230,7 +231,8 @@ AND t.table_name=?;`,
kcu.REFERENCED_COLUMN_NAME, kcu.REFERENCED_COLUMN_NAME,
rc.MATCH_OPTION, rc.MATCH_OPTION,
rc.UPDATE_RULE, rc.UPDATE_RULE,
rc.DELETE_RULE ,kcu.table_schema rc.DELETE_RULE ,
kcu.table_schema
Having Having
kcu.table_schema = ? kcu.table_schema = ?
AND kcu.referenced_column_name IS NOT NULL AND kcu.referenced_column_name IS NOT NULL
@ -241,60 +243,78 @@ AND t.table_name=?;`,
relationListAll: { relationListAll: {
default: { default: {
sql: ` sql: `SELECT
SELECT kcu.constraint_name AS cstn,
kcu.CONSTRAINT_NAME AS cstn, kcu.table_name AS tn,
kcu.TABLE_NAME AS tn, kcu.column_name AS cn,
kcu.COLUMN_NAME AS cn, kcu.position_in_unique_constraint AS puc,
kcu.POSITION_IN_UNIQUE_CONSTRAINT AS puc, kcu.referenced_table_name AS rtn,
kcu.REFERENCED_TABLE_NAME AS rtn, kcu.referenced_column_name AS rcn,
kcu.REFERENCED_COLUMN_NAME AS rcn, rc.match_option AS mo,
rc.MATCH_OPTION AS mo, rc.update_rule AS ur,
rc.UPDATE_RULE AS ur, rc.delete_rule AS dr,
rc.DELETE_RULE AS dr,
kcu.table_schema AS ts kcu.table_schema AS ts
FROM FROM
(SELECT (
SELECT
table_schema, table_schema,
CONSTRAINT_NAME, constraint_name,
TABLE_NAME, table_name,
COLUMN_NAME, column_name,
POSITION_IN_UNIQUE_CONSTRAINT, position_in_unique_constraint,
REFERENCED_TABLE_NAME, referenced_table_name,
REFERENCED_COLUMN_NAME referenced_column_name
FROM FROM
information_schema.KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE
WHERE WHERE
table_schema = :databaseName) AS kcu table_schema = :databaseName) AS kcu
INNER JOIN INNER JOIN
(SELECT (
CONSTRAINT_SCHEMA, SELECT
MATCH_OPTION, constraint_schema,
UPDATE_RULE, match_option,
DELETE_RULE, update_rule,
CONSTRAINT_NAME delete_rule,
constraint_name
FROM FROM
information_schema.REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS
WHERE WHERE
CONSTRAINT_SCHEMA = :databaseName) AS rc ON kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME constraint_schema = :databaseName) AS rc ON
AND kcu.table_schema = rc.CONSTRAINT_SCHEMA kcu.constraint_name = rc.constraint_name
AND kcu.table_schema = rc.constraint_schema
INNER JOIN INNER JOIN
(SELECT (
table_schema, TABLE_NAME, COLUMN_NAME SELECT
table_schema,
table_name,
column_name
FROM FROM
INFORMATION_SCHEMA.COLUMNS information_schema.COLUMNS
WHERE WHERE
table_schema = :databaseName AND TABLE_NAME IN (SELECT table_schema = :databaseName
TABLE_NAME AND table_name IN (
SELECT
table_name
FROM FROM
INFORMATION_SCHEMA.TABLES information_schema.TABLES
WHERE WHERE
table_schema = :databaseName table_schema = :databaseName
AND LOWER(TABLE_TYPE) = 'base table')) AS col ON col.table_schema = kcu.table_schema AND Lower(table_type) = 'base table')) AS col ON
AND col.table_name = kcu.TABLE_NAME col.table_schema = kcu.table_schema
AND col.table_name = kcu.table_name
AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL AND kcu.referenced_column_name IS NOT NULL
GROUP BY cstn , tn , rcn , cn , puc , rtn ,cn, mo , ur , dr , ts`, GROUP BY
cstn ,
tn ,
rcn ,
cn ,
puc ,
rtn ,
cn,
mo ,
ur ,
dr ,
ts`,
paramsHints: ['database'], paramsHints: ['database'],
}, },
}, },

Loading…
Cancel
Save