On Saturday, December 19, 2015 at 4:04:28 PM UTC-8, Kematzy wrote:
>
> Hi,
>
> I'm hoping for some wisdom on how to set up my PostgreSQL migration / Ruby 
> code to handle a scenario where I'm *storing a primary_key value that can 
> be either a String or an Integer in another table.*
>
> create_table(:my_table) do
>   primary_key :id
>   column :model_pk  :text
>   ....
> end
>
> And then I would add a row to MyTable like this:
>
>     MyTable.create(model_pk: model.id, ...)  # integer
>
>     or 
>
>    MyTable.create(model_pk: model.string_pk, ...)  # string primary_key
>
>
> When I run this code against Postgres, I get this error: 
>
>       Sequel::DatabaseError: PG::UndefinedFunction: ERROR:  operator does 
> not exist: text = integer
>
> How can I overcome this issue with a Sequel migration?
>
> Thanks for your time
>
>
Can you please provide a self contained example?  I tried to reproduce your 
issue with the following code, but I was not able:

DB.create_table(:my_table) do
  primary_key :id
  column :model_pk,  :text
end

class MyTable < Sequel::Model(:my_table)
end

MyTable.create(model_pk: 1)
MyTable.create(model_pk: '2')

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to