Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hieuk09 opened this issue Apr 11, 2024 · 0 comments

Comments

@hieuk09
Copy link

hieuk09 commented Apr 11, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant