On Sep 1, 2010, at 15:17 , Jeremy Evans wrote:

> On Sep 1, 2:35 pm, Dave Howell <[email protected]> wrote:
>> I needed to be able to figure out if a field of a model was a foreign key or 
>> not, and couldn't figure out a way to do that with the existing Sequel 
>> methods. I ended up resorting to this, which feels pretty bodgy:
> 

> Sequel doesn't currently have a method do this.  I'm not opposed to
> adding one, but before it's added it should be portable, with at least
> the commonly used shared database adapters implementing it
> (PostgreSQL, MySQL, SQLite).
> 
> Also, the method would have to be a Database instance method, similar
> to schema and indexes, not a Model instance method.

Oh, I completely agree. But that puts it pretty far outside the scope of my 
understanding. Each database library would need some form of "get me a list of 
the foreign keys on this table", with the databases that don't support foreign 
keys just returning an empty array. As is pretty clear from the code I used, 
it's going to to be very idiosyncratic to each database. 

On the other hand, it was really easy for me to Google up the query I needed 
for PostgreSQL, so I would imagine it wouldn't be too hard to find out how to 
do it for many of the other main databases. 


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to