Forum: Ruby on Rails Postgres problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cc24d46043aac77ee0cba0ad2c2d51f1?d=identicon&s=25 Jonas (Guest)
on 2007-06-11 16:09
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
Bce1d1b7c3ec7b577dcb42e254899e6b?d=identicon&s=25 Michael Schuerig (Guest)
on 2007-06-11 16:57
(Received via mailing list)
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 Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/
Cc24d46043aac77ee0cba0ad2c2d51f1?d=identicon&s=25 Jonas (Guest)
on 2007-06-11 17:20
Michael Schuerig 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 Schuerig
> mailto:michael@schuerig.de
> 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.
Bce1d1b7c3ec7b577dcb42e254899e6b?d=identicon&s=25 Michael Schuerig (Guest)
on 2007-06-11 20:54
(Received via mailing list)
On Monday 11 June 2007, Jonas wrote:
> Michael Schuerig 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 Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/
This topic is locked and can not be replied to.