You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Partitioning with the email seemed to me the best way to integrate with Devise, which will be able to efficiently look for a user by email.
Signing up goes well, but when I try to log in, I end up with the following error:
NoMethodError: undefined method `first' for #<User email: "[email protected]">
The error is located here: orm_adapter-cequel (1.0.1) lib/cequel/record/orm_adapter.rb:61:in 'find_first'.
From what I've gathered, find_first tries to build a scope using the given options to query the DB and to get the first record by calling first on that scope.
conditions only contains an email key with value [email protected]. In the second step, this resolves to applying this key as a "primary key scope", which ends up restricting the scope to a single User instance.
I guess it's because of this behavior of #[] (from cequel/cequel:lib/cequel/record/record_set.rb):
# If {#[]} is used successively to specify all of the columns of a primary# key, the result will be a single {Record} or a {LazyRecordCollection},# depending on whether multiple values were specified for one of the key# columns. In either case, the record instances will be unloaded.
Because of my relational-like table, where a partition key (email) always maps to a single User instance, #[] will always return a single Record instance.
I guess find_first should call first on the returned scope only if scope is an instance of RecordSet?
The text was updated successfully, but these errors were encountered:
I'm trying to use
cequel-devise
with... Devise ^^I have a User model:
Partitioning with the email seemed to me the best way to integrate with Devise, which will be able to efficiently look for a user by email.
Signing up goes well, but when I try to log in, I end up with the following error:
The error is located here:
orm_adapter-cequel (1.0.1) lib/cequel/record/orm_adapter.rb:61:in 'find_first'
.From what I've gathered,
find_first
tries to build a scope using the given options to query the DB and to get the first record by callingfirst
on that scope.scope
is assigned the following values:scope = klass.all #=> User
scope = apply_secondary_index_scope(scope, conditions) || apply_primary_key_scope(scope, conditions) #=> User['[email protected]'] => #<User:0x007f8bc4d0e6c8>
conditions
only contains anemail
key with value[email protected]
. In the second step, this resolves to applying this key as a "primary key scope", which ends up restricting the scope to a singleUser
instance.I guess it's because of this behavior of
#[]
(fromcequel/cequel:lib/cequel/record/record_set.rb
):Because of my relational-like table, where a partition key (email) always maps to a single User instance,
#[]
will always return a singleRecord
instance.I guess
find_first
should callfirst
on the returned scope only if scope is an instance ofRecordSet
?The text was updated successfully, but these errors were encountered: