[Nitro] [NP.ORG] Nitro/Og Fora daily diggest
george.moschovitis at gmail.com
george.moschovitis at gmail.com
Thu Mar 22 06:29:12 EDT 2007
>From gmosx.myopenid.com
Date: Thu Mar 22 07:59:02 UTC 2007
Subject: RE:
In-Reply-To: http://www.nitroproject.org/fora/posts/view/54
Message-ID: http://www.nitroproject.org/fora/posts/view/56
I am aware of this 'bug'. The problem is I am not sure how the behaviour should be altered. The current implementation allows code like this:
<code>
unless obj.save
flash[:msg] = obj.validation_errors
redirect :error
else
flash[:msg] = "everything ok"
redirect :ok
end
</code>
I am not sure which is the best way to alter the current interface. Any ideas?
regards,
George.
>From gmosx.myopenid.com
Date: Thu Mar 22 07:55:19 UTC 2007
Subject: RE:
In-Reply-To: http://www.nitroproject.org/fora/posts/view/52
Message-ID: http://www.nitroproject.org/fora/posts/view/55
<blockquote>And I think there might be the possibility of table name collision</blockquote>
That's why I included the prefix initially. But perhapswe could skip the prefix and specially handle the collision cases.
-g.
>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.
More information about the Nitro-general
mailing list