List Info

Thread: Nitro/Og Fora daily diggest




Nitro/Og Fora daily diggest
user name
2007-03-22 05:11:52
---------- Forwarded message ----------
From: george.moschovitisgmail.com
<george.moschovitisgmail.com>
Date: Mar 22, 2007 2:05 AM
Subject: [NP.ORG] Nitro/Og Fora daily diggest
To: george.moschovitisgmail.com


>From judson.myopenid.com
Date: Wed Mar 21 19:47:50 UTC 2007
Subject: Validation and silent failures
Message-ID: http:/
/www.nitroproject.org/fora/posts/view/54

Here's an annoying bug: You create a new model object.  You
obj.save.
Later, you try to pull the object out of the store and get
nil.  Why?
Because you put a validate_unique, and your new object was
made
invalid as a result.  This is a bug in your code.

Og doesn't really help make this easier to find, though.  Is
there a
good reason not to have failed validations raise an
exception?

The only reason I can think of (you're knowingly creating
duplicates
and using validate_unique to prevent that) is easily solved
by

obj.save rescue Og::ValidationException nil

>From judson.myopenid.com
Date: Wed Mar 21 19:35:10 UTC 2007
Subject: RE:
In-Reply-To: http:/
/www.nitroproject.org/fora/posts/view/44
Message-ID: http:/
/www.nitroproject.org/fora/posts/view/53

I agree that the implementation would be non-trivial.  I
don't
necessarily agree that there wouldn't be much benefit.  As
it stands,
valid_unique has the possibility of a race condition.

Moreover, though, I tend to be of a philosophy that says
"make the
DBMS do as much work as possible."

>From judson.myopenid.com
Date: Wed Mar 21 19:32:10 UTC 2007
Subject: RE:
In-Reply-To: http:/
/www.nitroproject.org/fora/posts/view/50
Message-ID: http:/
/www.nitroproject.org/fora/posts/view/52

<blockquote>Use object.id instead of object.oid (like
the AR guys do)
</blockquote>

On the one hand, in general one shouldn't be using
object.oid in
client code anyway.  Practically speaking, I've used it to
avoid
evolution/has_many/STI issues, so this change would break
some code a
tiny little bit.

On the other, why?  .oid is clear as a default PK.  .id
looks like
object_id (and masks .id (which is deprecated anyway, but
still valid
Ruby))  Just because AR does?

<blockquote>Skip the table prefix 'og' by default, ie
the class User
will be serialized to the user table </blockquote>

I've come to be rather fond of the og prefix for table
names,
personally.  And I think there might be the possibility of
table name
collision - something about certain DBMSs creating tables in
new DBs
for managing them or something.

Mostly this is just infernal advocacy.  I could go either
way, really.




--
This mail is automatically generated from the http://nitroproject.org/
fora
digest robot. It presents the discussions in the fora during
the last 24 hours.
Do not reply to this email.


-- 
http://blog.gmosx.com
http://cull.gr
http://www.joy.gr
http://nitroproject.org
_______________________________________________
Nitro-general mailing list
Nitro-generalrubyforge.org
h
ttp://rubyforge.org/mailman/listinfo/nitro-general

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )