# PG\_Namespace cartesian join in postgresql\_adapter.rb

**URL:** <https://www.ruby-forum.com/t/pg-namespace-cartesian-join-in-postgresql-adapter-rb/135843>\
**Category:** Rails\
**Created:** [April 25, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/pg-namespace-cartesian-join-in-postgresql-adapter-rb/135843 "2008-04-25T16:44:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [April 25, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/pg-namespace-cartesian-join-in-postgresql-adapter-rb/135843/1 "2008-04-25T16:44:35Z")

</div>

I’m working on a patch to Rails 2.0.2 to address a cartesian join with  
PG\_namespace in activerecord-2.0.2/lib/active\_record/  
connection\_adapters/postgresql\_adapter.rb. (around line 559 or so).

What I’m wondering is this: did the original author intend to  
retrieve the namespace (schema) for the database object (the sequence  
that feeds the primary key, in this case), and if so, what was the  
reason? Its probably a good one, and I’d like the patch to do the  
necessary in the correct fashion. The current query doesn’t return  
the schema name, so I’m thinking maybe it should, but Rails works fine  
without it, since the convention (!) is to have the table and sequence  
in the same schema namespace, which is in the login’s search path in  
PostgreSQL.

As an old, crusty DBA/developer, I’d prefer to have a trigger populate  
the surrogate primary key, but I understand this is not the One True  
Rails Way, so I’m not going to fight it. (Not here, anyway. I’ll  
hack my own code to do what I think it needs to do.)

Any thoughts? Please share…

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [April 25, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/pg-namespace-cartesian-join-in-postgresql-adapter-rb/135843/2 "2008-04-25T16:45:46Z")

</div>

On Apr 25, 3:39 pm, Bob [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m working on a patch to Rails 2.0.2 to address a cartesian join with  
> PG\_namespace in activerecord-2.0.2/lib/active\_record/  
> connection\_adapters/postgresql\_adapter.rb. (around line 559 or so).

You might want to try this over on the rubyonrails-core mailing-list,  
it’s probably more appropriate in this case.

Fred

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [April 25, 2008, 5:09pm UTC](https://www.ruby-forum.com/t/pg-namespace-cartesian-join-in-postgresql-adapter-rb/135843/3 "2008-04-25T17:09:17Z")

</div>

Will do, Fred. Thanks for the tip.

Bob

On Apr 25, 9:45 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
