# Postgres problem

**URL:** <https://www.ruby-forum.com/t/postgres-problem/106519>\
**Category:** Rails\
**Created:** [June 11, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/postgres-problem/106519 "2007-06-11T16:09:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonas](https://www.ruby-forum.com/u/jonas)\
**Post date:** [June 11, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/postgres-problem/106519/1 "2007-06-11T16:09:44Z")

</div>

I get the following error:

* * *

PGError: ERROR: syntax error at or near “default”  
RAD 1: SELECT \* FROM ivr\_menus ORDER BY default LIMIT 20 OFFSET 0  
^  
: SELECT \* FROM ivr\_menus ORDER BY default LIMIT 20 OFFSET 0

* * *

Why?  
Table definition:

class CreateIvrMenus \< ActiveRecord::Migration  
def self.up  
create\_table :ivr\_menus do |t|  
t.integer :parent\_id  
t.string :name, :limit =\> 20  
t.integer :schedule\_id  
t.string :open\_phrase  
t.string :close\_phrase  
t.integer :close\_action  
t.string :close\_action\_value  
t.integer :timeout\_action  
t.string :timeout\_action\_value  
t.string :timeout\_phrase  
end  
end

def self.down  
drop\_table :ivr\_menus  
end  
end

---

<div class="post-metadata">

**Author:** ![jonas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonas](https://www.ruby-forum.com/u/jonas)\
**Post date:** [June 11, 2007, 4:57pm UTC](https://www.ruby-forum.com/t/postgres-problem/106519/2 "2007-06-11T16:57:32Z")

</div>

On Monday 11 June 2007, Jonas wrote:

> * * *
> 
> Why?

Because default is an SQL keyword. You need to provide a column name (or  
rather an expression) and optionally either ASC or DESC.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)

---

<div class="post-metadata">

**Author:** ![jonas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonas](https://www.ruby-forum.com/u/jonas)\
**Post date:** [June 11, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/postgres-problem/106519/3 "2007-06-11T20:54:14Z")

</div>

On Monday 11 June 2007, Jonas wrote:

> Michael S. wrote:
> 
> > On Monday 11 June 2007, Jonas wrote:
> > 
> > > * * *
> > > 
> > > Why?
> > 
> > Because default is an SQL keyword. You need to provide a column  
> > name (or rather an expression) and optionally either ASC or DESC.

> But I do not have a column called “default”. I do not understand  
> where the word “default” comes from in the query.

To give us a chance of solving your problem you’ll have to show us the  
code that results in this query being executed

> PGError: ERROR: syntax error at or near “default”  
> RAD 1: SELECT \* FROM ivr\_menus ORDER BY default LIMIT 20 OFFSET 0  
> ^
> 
> : SELECT \* FROM ivr\_menus ORDER BY default LIMIT 20 OFFSET 0

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)

---

<div class="post-metadata">

**Author:** ![jonas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jonas](https://www.ruby-forum.com/u/jonas)\
**Post date:** [June 11, 2007, 5:20pm UTC](https://www.ruby-forum.com/t/postgres-problem/106519/4 "2007-06-11T17:20:23Z")

</div>

Michael S. wrote:

> On Monday 11 June 2007, Jonas wrote:
> 
> > * * *
> > 
> > Why?
> 
> Because default is an SQL keyword. You need to provide a column name (or  
> rather an expression) and optionally either ASC or DESC.
> 
> Michael
> 
> –  
> Michael S.  
> [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Michael Schürig | Sentenced to making sense](http://www.schuerig.de/michael/)

But I do not have a column called “default”. I do not understand where  
the word “default” comes from in the query.
