-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Relation#last doesn't respect as
#64
Comments
Sorry for not addressing this, it's more tricky than it seems to be, because Notice that We have a dedicated API for fetching a single tuple: I would suggest doing this if you really want to have these methods available on repos with automapping: def first
users.limit(1).as(:entity).first
end
def last
users.limit(1).as(:entity).reverse.first
end I'll close this, it's not going to be changed in rom. I may even remove |
@solnic Thanks for getting back. No worries. 👍 |
Thanks for explaining this @solnic. It's something I hadn't thought of, but it's a terrific insight. I have one misunderstanding. It's probably my fault :) Did you mean to have the example code-block as:
(instead of calling Or does |
since we add |
ah, I see. so it doesn't matter because you're just materializing a single element |
@cllns exactly. I should mention that |
thanks! Yes, I saw that distinction and understand it :) |
I'm using
rom-sql
viarom-repository
as integration withhanami-model
.From my repository, if I use
#first
withas
it works fine:But this isn't respected with
#last
:To overcome to this problem, I implemented
#last
as follow:The complete setup can be found here: https://github.com/hanami/model/blob/6ea119ebc308cd745fa03d5e7729678bc16d6dd2/test/support/fixtures.rb#L28
The text was updated successfully, but these errors were encountered: