Hi, folks.

I've been experimenting with implementing the triggers, schemas, and
functions mentioned in a talk by Marcus Hagander, presented at PGDay
15, called "A Tardis for your ORM"[1].  I finally got it working,
after spending some quality time with the postgresql manual and adding
the few bits he left out of the talk and slides.  In the talk, he
talks about how result-caching and connection pooling can cause
"interesting" behavior with ORMs when making use of it the views.
Here's why:

  databasename=# set search_path = 'tardis';
  databasename=# select column from tablename where ....;
  (some result)
  databasename=# set history.timestamp = '2016-02... (sometime in the past)';
  databasename=# select column from tablename where ....;
  (an older result!)
  databasename=# set history.timestamp = now;
  databasename=# select column from timestamp where ....;
  (the current result again)

The search_path and history.timestamp are per-connection values, I
believe. And even if they weren't, sending the same query after
changing history.timestamp gives different values - which is the
purpose of the whole setup, of course.  From what I can tell, Sequel
doesn't automatically cache results of queries, which is good.

So, two specific questions:

* Is there a Sequel wrapper for these 'set' queries? It looks like
search_path is expected to only be set as a parameter on the connect
method.

* What would I need to set in order to have multiple different
connections to the same database in an application, each with
different values for search_path and history.timestamp?  I'm
envisioning having whatever normal behavior is used for the 'current'
version of data, which would work entirely out of the public schema,
and completely unaware of the history mechanism... and then also
having an additional connection which queries only from the 'tardis'
schema and changes history.timestamp as it needs.

Sequel rocks.  Thanks for all the hard work you've done on it,

[1] The talk Magnus gave is here https://www.youtube.com/watch?v=JsO551E7ySY
and the slides here, for anyone curious:
http://pgday.ru/files/papers/9/pgday.2015.magnus.hagander.tardis_orm.pdf

-- 
Chris Riddoch
http://www.syntacticsugar.org/

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