Skip to content

User exists? instead of find_first#5169

Open
Dijkztra wants to merge 2 commits intoheartcombo:mainfrom
Dijkztra:use--exists
Open

User exists? instead of find_first#5169
Dijkztra wants to merge 2 commits intoheartcombo:mainfrom
Dijkztra:use--exists

Conversation

@Dijkztra
Copy link

@Dijkztra Dijkztra commented Nov 29, 2019

Issue: #5168

Benchmark in progress

@sourcelevel-bot
Copy link

Hello, @Dijkztra! This is your first Pull Request that will be reviewed by SourceLevel, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

raw = Devise.friendly_token
enc = OpenSSL::HMAC.hexdigest(@digest, key, raw)
break [raw, enc] unless klass.to_adapter.find_first({ column => enc })
break [raw, enc] unless klass.exists?({ column => enc })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the another change you was using { key: value } and now { key => value }, what do you think about use one as default, I suggest { key: value }

@carlosantoniodasilva
Copy link
Member

@Dijkztra thanks for your contribution.

Devise uses https://github.com/ianwhite/orm_adapter in order to work with Active Record and Mongo without having to worry about specifics of each, which is why it uses to_adapter.find_first. I'm sure there's a slight gain here, as I understand exists? is meant to be faster, so if ORM Adapter provided us with a way to run it under the hood, we'd be all in in those spots. For now, however, I think we'll stick with find_first.

I am also unsure if mongo is working 100% in master right now, but we'll take a look at that eventually.

@carlosantoniodasilva
Copy link
Member

I want to remove orm_adapter: #5823, so we might be able to implement something like this on our own side now.

@carlosantoniodasilva carlosantoniodasilva self-assigned this Feb 13, 2026
@carlosantoniodasilva carlosantoniodasilva added this to the 5.1.0 milestone Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants