On Monday, October 8, 2012 7:56:04 AM UTC+2, David Lee wrote:
>
> So apparently the documentation for how to use PGRow is wrong.
> I got the NoMethodError resolved by extending the Database object instead 
> of Sequel:
>
> Sequel::Model.db.extension :pg_row
>
>
The documentation gives the following example:

  DB.extension(:pg_array, :pg_row)
 
It does not show an example using Sequel.extension, so I'm not sure where 
you got that.

Also, it seems like calling register_row_type on the same type will 
> overwrite the previously registered row type definition. I'm not sure if 
> there are memory leak worries, since the implementation looks like it 
> creates an anonymous class for every row type registration.
>

Assuming nothing references the anonymous class it creates, it should be 
garbage collected, but that's not something I tested.  
 

> Now the problem remains of making row types only visible to a certain 
> database connection for thread/transactional safety. Right now, registering 
> a changed row type is not thread safe since it modifies the row type 
> registration on the Database object, which is shared among threads (a 
> thread inside a transaction will see a new row type in Rubyland even though 
> the database session doesn't see the new row type since it's inside a 
> transaction).
>
> Any tips on how I might make row type in Rubyland correspond with the row 
> type definition visible inside the connection session?
>

I would not recommend attempting to register connection-specific row-types 
with the pg_row extension, as it was not designed for this use case.  The 
use case sounds dubious to me, but assuming I had the need, I'd probably 
not register the row type, have the values be returned as text, and then do 
the parsing myself using the parser provided by the extension.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/LCObWI12W8MJ.
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