dkubb changed the topic of #datamapper to: Datamapper v1.2.0 | Mailing List: http://is.gd/aa9D | Logs: http://is.gd/qWAL7V | DataMapper 2 Renamed to ROM, see #rom-rb for development
lnormous has joined #datamapper
kenphused has quit [Remote host closed the connection]
kenphused has joined #datamapper
mbj has quit [Quit: leaving]
jeremyevans has quit [Ping timeout: 256 seconds]
jeremyevans has joined #datamapper
zombor_ has quit [Remote host closed the connection]
v0n has joined #datamapper
northrup has joined #datamapper
ckrailo has joined #datamapper
ckrailo has quit [Quit: Computer has gone to sleep.]
kenphused has quit [Remote host closed the connection]
kenphused has joined #datamapper
jeremyevans_ has joined #datamapper
elnormous has joined #datamapper
v0n has quit [*.net *.split]
northrup has quit [*.net *.split]
jeremyevans has quit [*.net *.split]
lnormous has quit [*.net *.split]
ckrailo has joined #datamapper
<dkubb>
!memo mbj would you have a problem if I configured coveralls/simplecov for mutant?
<Cinchy>
dkubb: Memo recorded for mbj.
jhn has joined #datamapper
elnormous has quit [Ping timeout: 248 seconds]
jhn has quit [Ping timeout: 268 seconds]
myobie has joined #datamapper
myobie has quit [Client Quit]
myobie has joined #datamapper
myobie has quit [Quit: myobie]
ckrailo has quit [Quit: Computer has gone to sleep.]
solnic has quit [Read error: Connection reset by peer]
postmodern has joined #datamapper
brianpWins has joined #datamapper
kapowaz has joined #datamapper
solnic_ has quit [Quit: Leaving...]
elnormous has joined #datamapper
mbj has joined #datamapper
myobie_ has joined #datamapper
snusnu has quit [Quit: Leaving.]
Sylvain2 has quit [Read error: Connection reset by peer]
Sylvain2 has joined #datamapper
Sylvain2 has quit [Quit: Leaving.]
Sylvain1 has joined #datamapper
lnormous has joined #datamapper
<lnormous>
has anyone tried using ParanoidBoolean in combination with a unique key
<lnormous>
It seems if I delete a record it gets marked as deleted. When I try and create a new record with a unique field (in this case user email), DataMapper allows it and then throws an exception because the database rejects it.
mbj has quit [Read error: Connection reset by peer]
v0n has quit [Ping timeout: 276 seconds]
<namelessjon>
lnormous: What is the 'correct' behaviour here? (I appreciate its not an exception, but what is it?)
<lnormous>
I guess :unique => true should be enforced regardless of ParanoidBoolean, because it sets the unique attribute on the database, so DataMapper should enforce it too
<namelessjon>
So that would prevent anyone from signing up twice?
<elnormous>
I think you can't use :unique => true on a field that has a ParanoidBoolean - at least not in a sane way - you need to write your own validation method
<namelessjon>
You probably would, yeah. It's why I'm asking what's actually the desired behaviour. I could have also seen 'undeleting' the user or creating a new user.
<elnormous>
well, I guess *my* desired behavious is that the database would know about the deleted flag, and allow me to create the record
<elnormous>
but that's an unreasonable ask :)
<namelessjon>
What would you then expect to happen when you deleted the user again?
<elnormous>
I'm not sure it's about expectation - I understand why it all happens like it does
<elnormous>
I guess the problem is DataMapper does it's own uniqueness check, which passes because it ignored the records marked as deleted, but it fails when it tries to put it into the database because the column is marked as unique
<elnormous>
So DataMapper's uniqueness check should fail, because it should know that the database will be enforcing that :unique requirement
<elnormous>
but maybe that breaks something else
lnormous has quit [Quit: Leaving]
<elnormous>
haha, totally didn't realise I had two xchat windows open
elnormous is now known as lnormous
<namelessjon>
Well, it would stop the signing up with the deleted email if it worked like that, but I don't think it would break anything
<lnormous>
i meant a pull request to change datamapper behaviour might break things
<namelessjon>
Oh yeah, the behavioural change applied generally could do so, yes.
<namelessjon>
So I'd probably suggest you add your own custom validation instead of the uniqueness one
<lnormous>
Do you have any idea what datamapper's uniqueness validator looks like
<lnormous>
I'm struggling to implement my own
<lnormous>
seems like a lot of edge cases
<namelessjon>
lnormous: Something like UserClass.with_deleted(:email => email, :fields => [:id]).nil?
<lnormous>
hmm
<lnormous>
does datamapper validate all attributes when saving or just those that have changed?
<namelessjon>
It makes sure its valid (i.e. all), iirc.
<namelessjon>
So you probably need to add a check to make sure you're not finding yourself
<lnormous>
yup, them's the edge cases
<lnormous>
and how to differentiate between finding yourself, and finding another user who already has that e-mail address
rafaelfranca has quit [Remote host closed the connection]
<namelessjon>
check if you're saved, and your id matches
<namelessjon>
which is what the code right at the bottom of the method does
<namelessjon>
lnormous: So actually you can just do this, I think validates_uniqueness_of :email, :deleted
<namelessjon>
Hmm. No.
<namelessjon>
So you're probably better using your own validation.
<namelessjon>
I'm off, though
<lnormous>
I think I could allow multiple deleted records with the same e-mail address
<lnormous>
so yeah, that wouldn't work
<lnormous>
thanks for your help though
<namelessjon>
I guess you could take off the :unique validation on the column, and just use validates_uniqueness_of :email
<namelessjon>
Actually, that's probably what you want.
<namelessjon>
(Well, if you want multiple deleted accounts anyway)
<namelessjon>
Perhaps in that case, you'd be better with a ParanoidDateTime, so you could tell when they were deleted?
<namelessjon>
Bye
xybre is now known as pipework|dontban
pipework|dontban is now known as xybre
zombor has quit [Remote host closed the connection]
brianpWins has quit [Quit: brianpWins]
zombor_ has joined #datamapper
zombor_ has joined #datamapper
zombor_ has quit [Changing host]
brianpWins has joined #datamapper
zombor_ has quit [Remote host closed the connection]