Error in your foreign key creations instructions page.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, nodejs, postgresql
- Ambito
- databases, documentation
Direzione di ricerca
Inizia dalla sezione sulle chiavi esterne collegata nel tutorial sul database SQL dell’elenco Todo di LoopBack e confronta il relativo valore foreignKey con lo schema PostgreSQL prodotto dalla migrazione. Aggiorna l’esempio in modo che il vincolo documentato corrisponda al nome della colonna generata, quindi verifica che l’esempio Todo venga migrato correttamente su PostgreSQL.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
https://loopback.io/doc/en/lb4/todo-list-tutorial-sqldb.html#specify-the-foreign-key-constraints-in-todo-model
In your example below.
@model({
settings: {
foreignKeys: {
fk_todo_todoListId: {
name: 'fk_todo_todoListId',
entity: 'TodoList',
entityKey: 'id',
foreignKey: 'todoListId',
},
},
},
})
export class Todo extends Entity {
//etc.
}
When following the setup above to run database migration for my local postgresdb as part of todo example tutorial, I encountered the following error:
Cannot migrate database schema error: column "todoListId" referenced in foreign key constraint does not exist
at Parser.parseErrorMessage (/Users/andywongcheeming/Projects/poc/todo-list/node_modules/pg-protocol/dist/parser.js:283:98)
I was left puzzled why the instructions did not work as expected. I dig up online and my personal ChatGPT to understand if Postgres DB has case-sensitive when comes to table and field naming conventions. It turns out that it does.
When I go back and check my local postgres todo definitions via psql cli.
todo_db=# \d todo
Table "public.todo"
Column | Type | Collation | Nullable | Default
------------+---------+-----------+----------+---------
id | integer | | not null |
title | text | | not null |
desc | text | | |
iscomplete | boolean | | |
todolistid | integer | | |
It turns our the foreign key todolistid comes out as lower case by default when running Loopback db migration tool. The sample @model code above supplied as {foreignKey: 'todoListId'}.
I corrected it to use lower-case, dropped the database and started the migration all over again. The migration works this time.
Thus, I must ask - shouldn't the instructions be updated to use lowercase since the plugin creates tables and field names in lowercase by default?
- Lingua principale
- JavaScript
- Stelle
- 118
- Fork
- 184
- Merge medio
- 1g 22h
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
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 loopbackio/loopback-connector-postgresql
-
Partial JSON Update Apertafeature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
loopbackio/loopback-connector-postgresql#748 · 1 commento ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Tutte le issue di loopbackio/loopback-connector-postgresql
Issue simili
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100