[BUG] Invalid sequence name for PosgreSQL
class SomeModel extends \PhalconMvc\Model
{
public function getSchema()
{
return 'shemaname';
}
public function getSource()
{
return 'sometable';
}
}
exception 'PDOException' with message 'SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "sometable_id_seq" does not exist'
schema is missing, valid sequence name - "shemaname"."sometable_id_seq"
You are at the time of inserting data error?
I try fix it.
I don't think this need a fix, you can implement the getSequenceName in the controller to tell the ORM which sequence must be used. http://docs.phalconphp.com/en/latest/reference/models.html#auto-generated-identity-columns
@phalcon If i model set schema in PostgreSQL, An error occurs when you insert data, Of course, when the default public schema can not go wrong.
getSequenceName will return the full sequenceName it contains the schema?
Yes, but that happens because the sequence name was not set:
class SomeModel extends \PhalconMvc\Model
{
public function getSchema()
{
return 'shemaname';
}
public function getSource()
{
return 'sometable';
}
public function getSchemaName()
{
return 'sequence_name';
}
}
@phalcon You mean, like this, Will be right:
class SomeModel extends \PhalconMvc\Model
{
public function getSchema()
{
return 'shemaname';
}
public function getSource()
{
return 'sometable';
}
public function getSequenceName()
{
return "shemaname.sometable_id_seq";
}
}
@sjinks How do you see Best to specify the schema for PostgreSQL
@phalcon I've read the docs, of course getSequenceName() fix this issue. But I think framework itself must generate the correct common sequence name, otherwise it is a bug. getSequenceName() should be used if the sequence name is not a standard, but in this case it is a standard.