Verified Commit e891703e authored by Dave Long's avatar Dave Long
Browse files

Issue #3358609 by Arantxio, daffie, Chi, larowlan, xjm: Fix PostgeSQL column...

Issue #3358609 by Arantxio, daffie, Chi, larowlan, xjm: Fix PostgeSQL column name escaping in field constraints
parent 36c79386
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ protected function createFieldSql($name, $spec) {
    }

    if (!empty($spec['unsigned'])) {
      $sql .= " CHECK ($name >= 0)";
      $sql .= ' CHECK ("' . $name . '" >= 0)';
    }

    if (isset($spec['not null'])) {
+18 −0
Original line number Diff line number Diff line
@@ -307,4 +307,22 @@ public function testPgsqlSequences(): void {

  }

  /**
   * Tests column name escaping in field constraints.
   */
  public function testUnsignedField(): void {
    $table_name = 'unsigned_table';
    $table_spec = [
      'fields' => [
        'order' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
      ],
      'primary key' => ['order'],
    ];
    $this->schema->createTable($table_name, $table_spec);
  }

}