# Wild SQL -- public/500.html -- postgres-pr

**URL:** <https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493>\
**Category:** Rails\
**Created:** [May 3, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493 "2006-05-03T19:09:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wksmall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/b38774/32.png) [@wksmall](https://www.ruby-forum.com/u/wksmall)\
**Post date:** [May 3, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493/1 "2006-05-03T19:09:41Z")

</div>

Every page of my DEPOT on Postgresql rails app now gets an error from  
postgres-pr about  
some wild left-join SQL that has nothing to do with my tables:

SQL (0.000000) NameError: undefined local variable or method  
`errors’ for  
#PostgresPR::Connection:0x3b200c0: SELECT a.attname,  
format\_type(a.atttypid,  
a.atttypmod), d.adsrc, a.attnotnull  
FROM pg\_attribute a LEFT JOIN pg\_attrdef d  
ON a.attrelid = d.adrelid AND a.attnum = d.adnum  
WHERE a.attrelid = ‘line\_items’::regclass  
AND a.attnum \> 0 AND NOT a.attisdropped  
ORDER BY a.attnum

Any idea where the wild sql comes from ? If I stop everything and swap  
out the  
database.yml so it points to the msysql database, and restart, it works  
fine as before.  
Win xpsp2, ruby 1.8.4, rails 1.1.2, postgres-pr (0.4.0)

---

<div class="post-metadata">

**Author:** ![wksmall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/b38774/32.png) [@wksmall](https://www.ruby-forum.com/u/wksmall)\
**Post date:** [May 3, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493/2 "2006-05-03T19:09:53Z")

</div>

I’m quite sure it’s part of ActiveRecord’s auto discovery process.

Won’t happen nearly as often in production mode. 🙂

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![wksmall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/b38774/32.png) [@wksmall](https://www.ruby-forum.com/u/wksmall)\
**Post date:** [August 3, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493/3 "2006-08-03T14:22:08Z")

</div>

I’ll damn make sure that bug doesn’t get into production mode. Okay  
then. Any ideas on  
how to fix it? Any ideas at all? Please? A wee little hint?

Warren S.

---

<div class="post-metadata">

**Author:** ![wksmall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/b38774/32.png) [@wksmall](https://www.ruby-forum.com/u/wksmall)\
**Post date:** [August 3, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493/4 "2006-08-03T14:22:58Z")

</div>

Why do you think it’s a bug?

ActiveRecord needs to know about the schema in order  
to do it’s magic. In production, it does this each  
time. This allows you to add columns to your DB and  
not restart everything.

In production, it assumes the schema won’t be changing,  
so it only needs to do this once.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![wksmall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/b38774/32.png) [@wksmall](https://www.ruby-forum.com/u/wksmall)\
**Post date:** [August 3, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/wild-sql-public-500-html-postgres-pr/59493/5 "2006-08-03T14:22:59Z")

</div>

I didn’t recognize it as schema-finding sql. It looked loopy and was  
crashing my rails  
app. Postgresql was rejecting it for some reason other than it’s  
apparent loopiness which  
fooled me – it was actually a failure of the C connector on winxp, not  
postgresql or  
rails.

Warren S.
