I receive the following error when I try to save a panels view. I am using Drupal 5.5 with PostgreSQL.

    * warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "offset" LINE 1: ..., view_type, use_pager, pager_id, nodes_per_page, offset, li... ^ in /usr/local/apache2/htdocs/drupal/includes/database.pgsql.inc on line 125.
    * user warning: query: INSERT INTO panels_views (pvid, view, name, description, title, category, category_weight, view_type, use_pager, pager_id, nodes_per_page, offset, link_to_view, more_link, feed_icons, url_override, url, url_from_panel, contexts, allow_type, allow_nodes_per_page, allow_offset, allow_use_pager, allow_link_to_view, allow_more_link, allow_feed_icons, allow_url_override, allow_url_from_panel) VALUES (1, 'circle_events', 'circle_events', 'Events for Circle of Interest', '', 'Views', -1, 'page', 0, 0, 10, 0, 0, 0, 0, 0, '', 0, 'a:4:{i:0;a:5:{s:4:"type";s:7:"context";s:7:"context";s:3:"any";s:5:"panel";s:1:"0";s:5:"fixed";s:0:"";s:5:"label";s:16:"OG: Group nid(s)";}i:1;a:5:{s:4:"type";s:7:"context";s:7:"context";s:3:"any";s:5:"panel";s:1:"0";s:5:"fixed";s:0:"";s:5:"label";s:14:"Calendar: Year";}i:2;a:5:{s:4:"type";s:7:"context";s:7:"context";s:3:"any";s:5:"panel";s:1:"0";s:5:"fixed";s:0:"";s:5:"label";s:15:"Calendar: Month";}i:3;a:5:{s:4:"type";s:7:"context";s:7:"context";s:3:"any";s:5:"panel";s:1:"0";s:5:"fixed";s:0:"";s:5:"label";s:13:"Calendar: Day";}}', 0, 0, 0, 0, 0, 0, 0, 0, 0) in /usr/local/apache2/htdocs/drupal/includes/database.pgsql.inc on line 144.
CommentFileSizeAuthor
#7 panels-DRUPAL-5--2.pgsql-offset.patch905 bytessun

Comments

eleybourn’s picture

offset is a reserved word. You can get around this by quoting the word in double quotes.
ie
pager_id, nodes_per_page, "offset", link_to_view

sime’s picture

Title: Syntax Errors Creating Panels View » "offset" reserved in PostgreSQL
jruberto’s picture

Yep, add these few lines to panels_views.install and it will work in PostgreSQL. I don't know enough about PostgreSQL to say so with any authority, but it might be better to just put all the field names in quotes?

  $fields = panels_views_pane_fields();
  $sql = "";
  foreach ($fields as $field => $data) {
    if ($sql) {
      $sql .= ', ';
    }
    /*  start postgres fix  */
    if ($field == "offset") {
        $field = '"offset"';        // offset is a reserved word in postgres, needs to be quoted
    }
    /*  end postgres fix  */
    $sql .= $field . ' ' . $data['definition'];
  }
  db_query("CREATE TABLE {panels_views} ($sql) /*!40100 DEFAULT CHARACTER SET utf8 */");
linuxpoet’s picture

Well a better solution would be to not use the word offset. However yes, if you quote the names you should be safe.

sun’s picture

sdboyer’s picture

Status: Active » Fixed

Yeah...ugly to fix it this way, but cleaner to do it this way and fix things more permanently when we're making bigger changes later.

Hack in #3 has been committed.

sun’s picture

Version: 5.x-2.0-beta2 » 5.x-2.0-beta3
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new905 bytes

Attached patch fixes coding-style of previous commit (indent & remark).

sdboyer’s picture

Status: Reviewed & tested by the community » Fixed

Picky picky ;p

committed, and since I had to roll a beta4b release anyway, I've included it in there.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.