CodeGen fails on PostgreSQL in seedLegacyHierarchyConfiguration: column "ROUTINE_SCHEMA" does not exist
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- postgresql, sql, typescript
- Área
- database
Línea de trabajo
La consulta que falla está en seedLegacyHierarchyConfiguration en packages/CodeGenLib/src/Database/manage-metadata.ts, y su entrecomillado de identificadores viene de packages/SQLDialect/src/postgresqlAutoQuote.ts. Empieza por la lista fija de nombres en mayúsculas sin comillas que hay allí y comprueba si ROUTINE_SCHEMA, ROUTINE_NAME y ROUTINE_TYPE deben estar en ella. Está terminado cuando la consulta devuelve filas en PostgreSQL con esos nombres sin comillas y pasa una prueba que ejecuta el texto de la consulta por AutoQuotePostgreSQLIdentifiers y comprueba que ningún nombre ROUTINE_ queda entre comillas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: 6.2.2 (LTS). The same code is on the next branch.
Database: PostgreSQL 16.
What happens
mj codegen ends with a failure on PostgreSQL when an application schema has a foreign key that points to its own table. The log shows:
Error seeding legacy hierarchy configuration: column "ROUTINE_SCHEMA" does not exist
Error seeding hierarchy configuration for legacy self-referencing foreign keys
MANAGE_METADATA: Metadata management reported a failure; see the errors logged above
CodeGen finished with 1 failure
The other CodeGen stages complete, but the command exits with an error code. A pipeline that commits the generated code only after a successful CodeGen step stops here.
Cause
The function seedLegacyHierarchyConfiguration in packages/CodeGenLib/src/Database/manage-metadata.ts runs this query through runQuery, which applies the PostgreSQL identifier quoting:
SELECT ROUTINE_SCHEMA AS "RoutineSchema", ROUTINE_NAME AS "RoutineName" FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'FUNCTION' AND LOWER(ROUTINE_NAME) LIKE '%root%id'
The quoting in packages/SQLDialect/src/postgresqlAutoQuote.ts keeps a fixed list of upper-case names bare. The list has INFORMATION_SCHEMA and ROUTINES, but it does not have ROUTINE_SCHEMA, ROUTINE_NAME or ROUTINE_TYPE. The result of AutoQuotePostgreSQLIdentifiers is:
SELECT "ROUTINE_SCHEMA" AS "RoutineSchema", "ROUTINE_NAME" AS "RoutineName" FROM INFORMATION_SCHEMA.ROUTINES WHERE "ROUTINE_TYPE" = 'FUNCTION' AND LOWER("ROUTINE_NAME") LIKE '%root%id'
PostgreSQL has these columns in lower case, so the quoted names are not found.
Why it does not show on each install
- SQL Server does not have the problem.
- The function returns before this query when there is no self-referencing foreign key outside the core schema. A PostgreSQL install with no such field does not reach the query.
Steps to reproduce
- Use a PostgreSQL database on 6.2.2.
- Have one table in an application schema with a foreign key to its own primary key, with entity metadata for it.
- Run mj codegen.
Suggested correction
One of these:
- Write the three column names in lower case in the query. The quoting does not change lower-case names. We use this as a local patch, and the query then returns the correct rows.
- Add ROUTINE_SCHEMA, ROUTINE_NAME and ROUTINE_TYPE to the list of bare names in postgresqlAutoQuote.ts.
A test that runs the query text through AutoQuotePostgreSQLIdentifiers and checks that no ROUTINE_ name is in quotes would catch this.
- Lenguaje dominante
- TSQL
- Estrellas
- 32
- Forks
- 7
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 504
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MemberJunction/MJ
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
MemberJunction/MJ#7094 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
MemberJunction/MJ#6971 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MemberJunction/MJ#6800 ·
Los mantenedores suelen responder en 1 día
-
Convention: saved-query discoverability follows Status — Approved is canon, Pending is a draftAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
MemberJunction/MJ#6746 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MemberJunction/MJ#6721 ·
Los mantenedores suelen responder en 1 día
Todos los issues de MemberJunction/MJ
Issues similares
-
cleanup follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
flakybot: issue priority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
GoogleCloudPlatform/cloud-sql-nodejs-connector#658 ·
Los mantenedores suelen responder en 1 día
-
factory:subtask
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
ConduitIO/conduit-connector-postgres#491 ·
Los mantenedores suelen responder en 1 día
-
SUM over a union column should skip an undefined slot, not throw ArrayIndexOutOfBoundsExceptionAbiertoexpression engine unshaved-yak
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día