[Nitro] Fwd: [NP.ORG] Nitro/Og Fora daily diggest

George Moschovitis george.moschovitis at gmail.com
Thu Mar 22 06:11:52 EDT 2007


---------- Forwarded message ----------
From: george.moschovitis at gmail.com <george.moschovitis at gmail.com>
Date: Mar 22, 2007 2:05 AM
Subject: [NP.ORG] Nitro/Og Fora daily diggest
To: george.moschovitis at gmail.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


More information about the Nitro-general mailing list