Problem/Motivation

In some SQL implementations (NuoDB in our case) "next" is a keyword, which causes errors when executing the db_select in job_scheduler_cron().

Proposed resolution

Change driver to escape keywords.

Remaining tasks

Escape potential keywords

User interface changes

API changes

Data model changes

Original report by xenophyle

In some SQL implementations (NuoDB in our case) "next" is a keyword, which causes errors when executing the db_select in job_scheduler_cron().

PDOException: SQLSTATE[42000]: Syntax error or access violation: -1 syntax error on line 4 WHERE (scheduled = ?) AND (next <= ?) ^ expected VALUE got < : SELECT job_schedule.* FROM {job_schedule} job_schedule WHERE (scheduled = :db_condition_placeholder_0) AND (next <= :db_condition_placeholder_1) ORDER BY next ASC OFFSET 0 FETCH 200; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => 1444398681 ) in job_scheduler_cron() (line 65 of sites/all/modules/contrib/job_scheduler/job_scheduler.module)

Comments

xenophyle created an issue. See original summary.

intrafusion’s picture

Status: Active » Postponed (maintainer needs more info)
mmjvb’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Would expect the driver to escape keywords. Or do it yourself in the query. Even for NuoDB keywords can be escaped by backticks.

intrafusion’s picture

Status: Active » Needs work

I think the correct way to deal with this would be to rename the fields using reserved keywords as the module already uses dB_select, etc. and you cannot escape keywords in these functions.

mmjvb’s picture

https://cgit.drupalcode.org/d7_nuodb_driver/tree/nuodb/database.inc
Checked the driver itself and found:

  /**
   * Escapes a field name string.
   *
   * Force all field names to be strictly alphanumeric-plus-underscore
   * and wrap the field name in backquote '`' characters.
   *
   * @param string $field
   *   The field name to escape.
   *
   * @return string
   *   The sanitized field name string.
   */
  public function escapeField($field) {
    return preg_replace('/[^A-Za-z0-9_.]+/', '', '`' . $field . '`');
  }

Looks like it has already been taken care of.

intrafusion’s picture

Status: Needs work » Closed (works as designed)