CodeGen fails on PostgreSQL in seedLegacyHierarchyConfiguration: column "ROUTINE_SCHEMA" does not exist
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, sql, typescript
- Ambito
- database
Direzione di ricerca
La query che fallisce si trova in seedLegacyHierarchyConfiguration in packages/CodeGenLib/src/Database/manage-metadata.ts, e il quoting degli identificatori deriva da packages/SQLDialect/src/postgresqlAutoQuote.ts. Inizia dalla lista fissa di nomi maiuscoli non quotati presente lì e verifica se ROUTINE_SCHEMA, ROUTINE_NAME e ROUTINE_TYPE debbano farne parte. Il lavoro è completo quando la query restituisce righe su PostgreSQL con questi nomi non quotati e un test passa eseguendo il testo della query attraverso AutoQuotePostgreSQLIdentifiers e verificando che nessun nome ROUTINE_ risulti quotato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TSQL
- Stelle
- 32
- Fork
- 7
- Merge medio
- 1g 16h
- PR unite (30g)
- 504
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MemberJunction/MJ
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
MemberJunction/MJ#7094 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
MemberJunction/MJ#6971 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MemberJunction/MJ#6800 ·
I maintainer di solito rispondono entro 1 giorno
-
Convention: saved-query discoverability follows Status — Approved is canon, Pending is a draftAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MemberJunction/MJ#6746 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MemberJunction/MJ#6721 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MemberJunction/MJ
Issue simili
-
flakybot: issue priority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
GoogleCloudPlatform/cloud-sql-nodejs-connector#658 ·
I maintainer di solito rispondono entro 1 giorno
-
factory:subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
SUM over a union column should skip an undefined slot, not throw ArrayIndexOutOfBoundsExceptionApertaexpression engine unshaved-yak
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Invalid-MissingHash/Commit/NotAC
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
azerothcore/azerothcore-wotlk#28636 ·
I maintainer di solito rispondono entro 1 giorno
-
bug has-work-around priority: high
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
liberation-data/drivine#908 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno