How to add a foreign key to a table?

2009-07-03 Thread S.Wojnowski
Hi, First of all, I have just been testing the sequel lib and want to to say , it's been pleasure to work with it so far ;)). However, I have failed to find any info on how to add a foreign key to my (already existing SQLite table). Is such a thing possible in the context of the latest version

Re: Lost for how to use Models and Associations

2009-07-03 Thread Charlton
I'm trying to do something similar (a directed graph). I have both a nodes table and a join table, nodenodes. Everything works fine but I would like to enforce a validates_unique on the join table that ensures that the ordered pair of (parent_id, child_id) doesn't get repeated: DB.create_table

Re: Lost for how to use Models and Associations

2009-07-03 Thread Jeremy Evans
On Jul 2, 11:51 pm, Charlton charlton.w...@gmail.com wrote: I'm trying to do something similar (a directed graph). I have both a nodes table and a join table, nodenodes. Everything works fine but I would like to enforce a validates_unique on the join table that ensures that the ordered pair

Re: to_xml

2009-07-03 Thread Jeremy Evans
On Jul 2, 2:47 pm, daniel_spaniel geu...@gmail.com wrote: Hi Jeremy,  I have seen a few posts about people asking for a to_xml method for a Sequel Model.  Is there something around with all the flair that AR has with its XMLSerializer?  It easy to make something super basic though, but I was

Re: How to add a foreign key to a table?

2009-07-03 Thread S.Wojnowski
  DB.alter_table(:table){add_foreign_key :column, :other_table} Thx Jeremy, it worked great ;)) I must have overlooked that method ;((. Below is a link to the piece of docs describing all that in more details( in case somebody else would run into this problem too :)) )

Finding Many To One Values

2009-07-03 Thread Scott LaBounty
I'm messing around with a poll of the day site (another example for my blog) and am running across an issue where I'm not sure the best way to solve it. I have a Poll table that has a Title, Question, Date and each of these can have many reponses. So I create the polls and then display one with

Re: Lost for how to use Models and Associations

2009-07-03 Thread Jeremy Evans
On Jul 3, 8:13 am, Charlton charlton.w...@gmail.com wrote: Thanks.That will work though, as you say, maybe not in the most efficient manner. Is there a mechanism to determine the error that is common across all database backends? It would be nice if I could defer the checking to the

Re: Finding Many To One Values

2009-07-03 Thread Jeremy Evans
On Jul 3, 10:57 am, Scott LaBounty slabou...@gmail.com wrote: I'm messing around with a poll of the day site (another example for my blog) and am running across an issue where I'm not sure the best way to solve it. I have a Poll table that has a Title, Question, Date and each of these can