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. 100
      packages/nocodb/src/lib/db/sql-client/lib/mysql/mysql.queries.ts

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

Loading…
Cancel
Save