Use parameterized query in getRemoteTableLocalName (#16651)

This PR updates the `isNameAvailable` function in
`getRemoteTableLocalName` to use parameterized queries instead of string
interpolation when querying the information_schema.

**Changes:**
- Replaced template literal interpolation with PostgreSQL's `$1`, `$2`
placeholder syntax
- Parameters are now passed as a separate array argument to
`dataSource.query()`

This follows best practices for database queries.
This commit is contained in:
Félix Malfait
2025-12-18 08:37:43 +01:00
committed by GitHub
parent 1e615f7102
commit 4e15f7fe13
@@ -21,7 +21,8 @@ const isNameAvailable = async (
) => {
const numberOfTablesWithSameName = +(
await coreDataSource.query(
`SELECT count(table_name) FROM information_schema.tables WHERE table_name LIKE '${tableName}' AND table_schema IN ('core', '${workspaceSchemaName}')`,
`SELECT count(table_name) FROM information_schema.tables WHERE table_name LIKE $1 AND table_schema IN ('core', $2)`,
[tableName, workspaceSchemaName],
)
)[0].count;