Hi Jeremy,

Thanks for your reply.

Actually, I was too rushed yesterday morning to fully understand the 
problem and therefore blamed the wrong thing.  My bad & my sincere 
apologies.

I now believe the problem seems to occur when collecting records via a 
*one_to_many* association.

You can see the entire codebase here 
[ https://github.com/kematzy/sequel-audited/tree/postgres-errors-example ] 
with the results fully outlined here 
[ 
https://github.com/kematzy/sequel-audited/blob/postgres-errors-example/Error-Output.md
 
].

I thought it was better to see the problem within the context rather than 
isolated, but if this is not suitable, please let me know and I will try to 
compress the code to minimum required.

PS: if you happen to see something stupid or wrong in the above codebase, 
please do let me know. ;-)

Kind regards,

Kematzy


On Monday, 21 December 2015 03:33:51 UTC+8, Jeremy Evans wrote:
>
> 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