Ticket #827 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

Column aliases crash at least syntax change

Reported by: rulcom Owned by: somebody
Priority: minor Milestone: 0.10.3
Component: Other Version: 0.10.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description

Examples: 1. Upper case "as"

class Book extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('bookName AS name', 'string');
    }
}

Doctrine::createTablesFromArray(array('Book'));

Leads to: Caught exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as name TEXT, PRIMARY KEY(id)) ENGINE = INNODB' at line 1. Failing Query: CREATE TABLE book (id BIGINT AUTO_INCREMENT, bookname as name TEXT, PRIMARY KEY(id)) ENGINE = INNODB

2. Spaces before "as"

class Book extends Doctrine_Record
{
    public function setTableDefinition()
    {
      $this->hasColumn('bookName  as name', 'string');
    }
}

Doctrine::createTablesFromArray(array('Book'));

$book = new Book();
$book->name = 'Some book';
$book->save();

$book = $conn->getTable('Book')->find(1);
echo $book->id; // <- this correct, contains "1"...
echo $book->name; // <- this is EMPTY!!

If replace "find(1)" to "findByName('Some book')" get exception: "Cannot find by: Name. Invalid column or relationship alias."

Change History

Changed 16 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [3949]) fixes #827

Note: See TracTickets for help on using tickets.