Skip to content

Commit cd0de6b

Browse files
add quotes around table name to avoid syntax errors
1 parent 3da9762 commit cd0de6b

File tree

1 file changed

+8
-8
lines changed
  • graphql-server/src/queryFactory/doltgres

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ export function useDB(dbName: string, refName?: string, isDolt = true): string {
1616

1717
export const listTablesQuery = `SELECT table_schema, table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema = $1 AND table_catalog = $2`;
1818

19-
export const columnsQuery = (schemaName: string, tableName: string) => {
20-
const table = tableName.includes(".")
21-
? tableName
22-
: `${schemaName || "public"}."${tableName}"`;
23-
return `DESCRIBE ${table};`;
24-
};
19+
export const columnsQuery = (schemaName: string, tableName: string) =>
20+
`DESCRIBE ${schemaName || "public"}."${tableWithoutSchema(tableName)}"`;
2521

2622
export const foreignKeysQuery = `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
2723
WHERE table_name=$1 AND table_schema=$2 AND table_catalog=$3
@@ -138,8 +134,12 @@ function getPKColsForRowsQuery(cs: t.RawRows): string[] {
138134
return cols;
139135
}
140136

141-
export const tableColsQueryAsOf = (tableName: string, refName: string) =>
142-
`DESCRIBE ${tableName} AS OF '${refName}'`;
137+
export const tableColsQueryAsOf = (
138+
tableName: string,
139+
refName: string,
140+
schemaName?: string,
141+
) =>
142+
`DESCRIBE ${schemaName || "public"}."${tableWithoutSchema(tableName)}" AS OF '${refName}'`;
143143

144144
export function getTableCommitDiffQuery(
145145
args: t.RowDiffArgs,

0 commit comments

Comments
 (0)