i have a log table, with a primary key defined by :

/**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\SequenceGenerator(sequenceName="log_id_seq", allocationSize=1, 
initialValue=1)
     */
    private $id;



This creates  :

CREATE SEQUENCE log_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE TABLE log (id INT NOT NULL, ... PRIMARY KEY(id) ...



Using the ORM I can insert into this table as expected.

Using the use Doctrine\DBAL\Connection I cannot :

use Monolog\Handler\AbstractProcessingHandler;
use Doctrine\DBAL\Connection;

class DoctrineDBALHandler extends AbstractProcessingHandler
{
...
  public function __construct(Connection $connection, $tableName, $level = 
Logger::DEBUG, $bubble = true)
    {
        $this->connection = $connection;
...
  protected function write(array $record)
    { 
     
      
        try {            
            $this->connection->insert($this->tableName, array('message' => 
$record['message'],'timestamp' => $record['datetime']->format('Y-m-d H:i:s'
),'from_ip' => $record['from_ip']));
        } catch (\Exception $e) { error_log($e->__toString());
        }
    }



Generates : Not null violation: 7 ERROR:  null value in column "id" 
violates not-null constraint


If I manually alter the table primary key to  
id serial NOT NULL

it resolves the issue. 

What am I doing wrong ?

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to