On Monday, July 20, 2015 at 5:44:42 AM UTC-6, Janko Marohnić wrote:
>
> Hi Jeremy,
>
> So, if I connect to a database, add an extension, and then connect to
> another database, that database will also have that extension. Not sure if
> it works for each extension, but it does with the "pg_array" extension.
>
> So, in this order of execution `legacy_db` is extensionless:
>
> require "sequel"
>
> legacy_db = Sequel.connect("postgres:///legacy_db")
> db = Sequel.connect("postgres:///db")
> db.extension :pg_array
>
> legacy_db.get(Sequel.lit("ARRAY[1,2,3]")) #=> "{1,2,3}"
>
> But if we first load the extension on the main `db`, and *then* connect
> to the legacy db, it will inherit the "pg_array" extension:
>
> require "sequel"
>
> db = Sequel.connect("postgres:///db")
> db.extension :pg_array
> legacy_db = Sequel.connect("postgres:///legacy_db")
>
> legacy_db.get(Sequel.lit("ARRAY[1,2,3]")) #=> [1,2,3]
>
> I expected that the extension only applies to database instances, and are
> not carried over to other databases. I'm not bothered by it, just wanted to
> check if this was intended.
>
Yes, that's by design. The pg_array extension modifies Postgres::PG_TYPES,
which is used to populate a new Postgres::Database object's
conversion_procs, so if you load the extension before a database, it will
pick up the conversion proc. But the rest of the extension is not loaded
into the Postgres::Database object.
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.