G
Gavin Kistner
A few days ago I posted a question on how to use ActiveRecord to
determine if the DB schema allows null values in a column or not. I got
no response, and I think that's because the feature doesn't exist.
That made me wonder "why oh why doesn't this ridiculously useful
feature exist?!" Oh, the things you could do with scaffolding if you
could determine not just what type of value a column is, but if it's
required. If the AR classes had rich methods that described the full
schema they reflected, joins to other classes per column, and so on.
Think of scaffolding that did client- and server-side validation of
required fields...that used forign-key references to create drop-downs
for associated tables. Oh, the automated beauty that could be realized!
Doing more digging, I assume that the reason these sorts of
deep-schema-inspection details don't exist in AR is that (from what I
can tell) not all DBs support this level of inspection in the
interfaces. MySQL, notably.
I'm a rails noob, just starting out. Perhaps I'm wrong.
If I'm correct...this seems a shame. Lowering the functionality to the
lowest common denominator. You can write a SQL select statement in
PostgreSQL to find out if a column may be null or not. I'm pretty sure
the same is true of MSSQL2k as well. Must the Good Guys be hamstrung
just because the weak happen to be so popular?
If these features have been omitted due to lack of inspection support
by some rdbms, what would people think of coming up with a set of
full-schema inspection methods, which would return nil if the db
adaptor didn't/couldn't support those methods? Would anyone be willing
to lend a hand to such a project?
determine if the DB schema allows null values in a column or not. I got
no response, and I think that's because the feature doesn't exist.
That made me wonder "why oh why doesn't this ridiculously useful
feature exist?!" Oh, the things you could do with scaffolding if you
could determine not just what type of value a column is, but if it's
required. If the AR classes had rich methods that described the full
schema they reflected, joins to other classes per column, and so on.
Think of scaffolding that did client- and server-side validation of
required fields...that used forign-key references to create drop-downs
for associated tables. Oh, the automated beauty that could be realized!
Doing more digging, I assume that the reason these sorts of
deep-schema-inspection details don't exist in AR is that (from what I
can tell) not all DBs support this level of inspection in the
interfaces. MySQL, notably.
I'm a rails noob, just starting out. Perhaps I'm wrong.
If I'm correct...this seems a shame. Lowering the functionality to the
lowest common denominator. You can write a SQL select statement in
PostgreSQL to find out if a column may be null or not. I'm pretty sure
the same is true of MSSQL2k as well. Must the Good Guys be hamstrung
just because the weak happen to be so popular?
If these features have been omitted due to lack of inspection support
by some rdbms, what would people think of coming up with a set of
full-schema inspection methods, which would return nil if the db
adaptor didn't/couldn't support those methods? Would anyone be willing
to lend a hand to such a project?