mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-11-10 10:29:12 +03:00
console: fix issues with replacing invalid graphql identifiers in table and column names
> This PR replaces all occurrences of invalid graphql identifiers in table and column names when tracking a table from the console. ### Description > ### Changelog - [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label. ### Affected components - [x] Console ### Related Issues Closes [7239](https://github.com/hasura/graphql-engine/issues/7239) https://github.com/hasura/graphql-engine-mono/pull/1888 GitOrigin-RevId: b6f719b0f1c270908a8717b08564a97c44d8c5bf
This commit is contained in:
parent
0655eb9183
commit
760406b851
@ -8,6 +8,7 @@
|
||||
- server: Relax the unique operation name constraint when adding a query to a query collection
|
||||
- server/bigquery: Fix issues related to adding and querying from non-US datasets (closes [6937](https://github.com/hasura/graphql-engine/issues/6937)).
|
||||
- console: add pagination on the Raw SQL results page
|
||||
- console: fix issues with replacing invalid graphql identifiers in table and column names
|
||||
|
||||
|
||||
## v2.0.3
|
||||
|
@ -87,7 +87,7 @@ export function escapeTableColumns(table: Table) {
|
||||
return getTableColumnNames(table)
|
||||
.filter(col => pattern.test(col))
|
||||
.reduce((acc: Record<string, string>, col) => {
|
||||
let newColName = col.replace(/\W+/, '_');
|
||||
let newColName = col.replace(/\W+/g, '_');
|
||||
if (/^\d/.test(newColName)) newColName = `column_${newColName}`;
|
||||
acc[col] = newColName;
|
||||
return acc;
|
||||
@ -98,7 +98,7 @@ export function escapeTableName(tableName: string): Nullable<string> {
|
||||
const pattern = /\W+|^\d/;
|
||||
if (!pattern.test(tableName)) return null;
|
||||
if (/^\d/.test(tableName)) tableName = `table_${tableName}`;
|
||||
return tableName.toLowerCase().replace(/\s+|_?\W+_?/, '_');
|
||||
return tableName.toLowerCase().replace(/\s+|_?\W+_?/g, '_');
|
||||
}
|
||||
|
||||
export const getTableColumn = (table: Table, columnName: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user