File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
graphql-server/src/queryFactory/dolt Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,18 @@ import { RawRows } from "../types";
5
5
6
6
export const columnsQuery = `DESCRIBE ??` ;
7
7
8
- export const foreignKeysQuery = `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
9
- WHERE table_name=? AND table_schema=?
10
- AND referenced_table_schema IS NOT NULL` ;
8
+ // Use ORDINAL_POSITION from INFORMATION_SCHEMA.COLUMNS to get the column's position within the table
9
+ export const foreignKeysQuery = `SELECT
10
+ kcu.*,
11
+ cols.ORDINAL_POSITION
12
+ FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS kcu
13
+ JOIN INFORMATION_SCHEMA.COLUMNS AS cols
14
+ ON kcu.TABLE_SCHEMA = cols.TABLE_SCHEMA
15
+ AND kcu.TABLE_NAME = cols.TABLE_NAME
16
+ AND kcu.COLUMN_NAME = cols.COLUMN_NAME
17
+ WHERE kcu.table_name = ?
18
+ AND kcu.table_schema = ?
19
+ AND kcu.referenced_table_schema IS NOT NULL` ;
11
20
12
21
export const indexQuery = `SELECT
13
22
table_name,
You can’t perform that action at this time.
0 commit comments