Skip to content

Commit dfc8df7

Browse files
authored
Merge pull request #468 from dolthub/liuliu/fix-index-type-check
Graphql: fix index type check
2 parents 44ef258 + a246f73 commit dfc8df7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

graphql-server/src/indexes/index.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function fromDoltRowsRes(rows: RawRow[]): Index[] {
3030
const cols = r.COLUMNS ? r.COLUMNS.split(",") : [];
3131
return {
3232
name: r.INDEX_NAME,
33-
type: getIndexType(cols, r.NON_UNIQUES === "1"),
33+
type: getIndexType(cols, r.NON_UNIQUES === 1),
3434
comment: r.COMMENTS,
3535
columns: cols.map(c => {
3636
return { name: c };

graphql-server/src/queryFactory/dolt/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,10 @@ async function getTableInfoWithQR(
512512
args.tableName,
513513
`${args.databaseName}/${args.refName}`,
514514
]);
515-
const idxRows = await query(qh.indexQuery, [args.tableName]);
515+
const idxRows = await query(qh.indexQuery, [
516+
args.tableName,
517+
`${args.databaseName}/${args.refName}`,
518+
]);
516519
return {
517520
tableName: args.tableName,
518521
columns: columns.map(c => column.fromDoltRowRes(c, args.tableName)),

graphql-server/src/queryFactory/dolt/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const indexQuery = `SELECT
2525
GROUP_CONCAT(non_unique) AS NON_UNIQUES,
2626
GROUP_CONCAT(column_name ORDER BY seq_in_index) AS COLUMNS
2727
FROM information_schema.statistics
28-
WHERE table_name=? AND index_name!="PRIMARY"
28+
WHERE table_name=? AND table_schema=? AND index_name!="PRIMARY"
2929
GROUP BY index_name;`;
3030

3131
export const tableColsQuery = `SHOW FULL TABLES WHERE table_type = 'BASE TABLE'`;

0 commit comments

Comments
 (0)