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

Incorrect mapping of column names when joining multiple tables #112

Open
lukinski opened this issue Jan 24, 2024 · 1 comment
Open

Incorrect mapping of column names when joining multiple tables #112

lukinski opened this issue Jan 24, 2024 · 1 comment

Comments

@lukinski
Copy link
Contributor

Hello,
I think we may get incorrect mapping of column names when using multiple joins, eg. executing following query:

SELECT sample.* FROM sample INNER JOIN joins ON joins.event_name = sample.event_name INNER JOIN secondary_joins ON secondary_joins.event_name = sample.event_name LIMIT 1

As a result we have:

#<Model:0x0000000108103318>

with attributes:

 {"sample.event_name"=>"some event 1",
 "sample.event_value"=>nil,
 "sample.enabled"=>false,
 "sample.date"=>Thu, 01 Jan 1970,
 "sample.datetime"=>1970-01-01 00:00:00 UTC,
 "sample.datetime64"=>nil,
 "sample.relation_uuid"=>nil,
 "sample.id"=>1}

accessing id of returned record throws an error:

> model.id
ActiveModel::MissingAttributeError: missing attribute 'id' for Model

In valid scenario, we should get following result:

#<Model:0x000000010a6fb070 event_name: "some event 1", event_value: nil, enabled: false, date: Thu, 01 Jan 1970, datetime: 1970-01-01 00:00:00 UTC, datetime64: nil, relation_uuid: nil, id: 1>

with attributes:

 {"event_name"=>"some event 1", 
"event_value"=>nil, 
"enabled"=>false, 
"date"=>Thu, 01 Jan 1970, 
"datetime"=>1970-01-01 00:00:00 UTC, 
"datetime64"=>nil,
"relation_uuid"=>nil, 
"id"=>1}

so id and other attrs should be accessible:

> model.id
=> 1
@lukinski
Copy link
Contributor Author

lukinski commented May 7, 2024

@PNixx can you roughly tell why is PR #113 now closed? Is the current behavior desirable? Thanks in advance for few words of explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant