On Thursday, July 23, 2020 at 5:39:45 PM UTC-7, andy schmidt wrote: > > The Postgres primary_key_sequence method caches the results of the > sequence lookup. If an unqualified table name is passed in it will store > the unqualified table name as the cache lookup key with the schema > qualified sequence as the value. If the search_path is changed to a > different schema and the primary_key_sequence method called again with an > unqualified table name it will return the sequence name qualified with the > previous schema. Is this a bug or maybe I am misusing the method? >
This isn't a bug, because support for changing the search_path at runtime wasn't planned. I suppose you could say it is a limitation. There are plenty of other database changes you can make at runtime by directly running SQL in the database that will result in Sequel returning the wrong data due to caching: DB.schema(:foo) # Sequel::DatabaseError DB.run "CREATE TABLE foo(id integer)" DB.schema(:foo) # no error DB.run "DROP TABLE foo" DB.schema(:foo) # no error In the above case, if you use Sequel's methods (DB.create_table, DB.drop_table), things are handled properly. I suppose I could add a method for changing the search path that would clear the related caches. It is also possible to disable the caching, but it would be pretty terrible for performance. 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/0196bb1d-b4de-4706-9954-8ef371869be9o%40googlegroups.com.
