Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`by_pk` causes stack overflow when used with single primary key while table define composite primary key

Aperta
#424 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql, ruby, sql
Ambito
databases

Direzione di ricerca

Start with the reported users.by_pk('0049d2d1-b433-48d7-818a-a2672ae05fa').one reproduction against the composite-primary-key users table. Trace how by_pk handles one value when the inferred schema has id and tenant_id keys; done means it raises an incorrect-number-of-arguments error instead of overflowing the stack.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug help wanted

Describe the bug

When using by_pk with one value while the table has composite primary key, ROM can raise stack overflow error.

To Reproduce

  • Create a table in DB:
create table users (
  id VARCHAR(50),
  tenant_id VARCHAR(50),
  primary key (id, tenant_id)
)
  • Run the below snippet
require "rom"

rom = ROM.container(:sql, 'postgres://localhost/test') do |config|
  config.relation(:users) do
    schema(infer: true)
    auto_struct true
  end
end

users = rom.relations[:users]
users.by_pk('0049d2d1-b433-48d7-818a-a2672ae05fa').one

Expected behavior

The error should be raised with incorrect number of argument message.

My environment

  • Affects my production application: NO
  • Ruby version: 3.3.0
  • OS: MacOS 14.4.1
Lingua principale
Ruby
Stelle
220
Fork
97
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rom-rb/rom-sql

Tutte le issue di rom-rb/rom-sql

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.