I see, I didn't know the model caches the database schema it gets from the 
Database object, but it makes sense from the performance standpoint. This 
really isn't an issue for me, using `Sequel::Database.extension` was a perfect 
solution. I just wanted to help new people who don't know about this order (one 
person experienced this "issue" in Hanami, he was using Sequel::Model instead 
of Hanami::Model). I'll then just send a PR for updating the pg_json 
documentation to mention the load order.

Thank you for the explanation, I now know much better how Sequel works.

> On 11 May 2016, at 22:25, Jeremy Evans <[email protected]> wrote:
> 
> On Wednesday, May 11, 2016 at 3:48:17 AM UTC-7, Janko Marohnić wrote:
> But schema parsing isn't strictly related to models, is it? I mean, you can 
> request `DB.schema(table_name)` without using models, and the schema is 
> cached on the database object. To me it seems that schema parsing is a 
> Database thing (which the model code uses), and thus it seems to me that it 
> should be fine that a database extension affects this code.
> 
> Another thing is that the pg_json extension already affects schema parsing, 
> so isn't the change I'm suggesting still inside the territory that pg_json 
> covers?
> 
> You could have loading the pg_json (and similar pg_*) extensions modify or 
> clear the Database schema cache, but I don't think that would help your case. 
>  When Model.set_dataset is called, it gets the schema from the Database 
> object and transforms it from an array to a hash.  So changes to the database 
> schema cache have no effect on models who have already parsed the schema.
> 
> The two decent options you have are:
> 
> 1) Fix your app so you have more control over initialization and can set 
> things up correctly (recommended)
> 2) Reset the dataset for all affected models so that the schema gets reparsed 
> (ugly hack)
> 
> Thanks,
> Jeremy
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "sequel-talk" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/sequel-talk/Ej2E0JJtjh4/unsubscribe 
> <https://groups.google.com/d/topic/sequel-talk/Ej2E0JJtjh4/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/sequel-talk 
> <https://groups.google.com/group/sequel-talk>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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