Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invalid sequence name for PosgreSQL #1022

Closed
beermeat opened this issue Aug 7, 2013 · 8 comments
Closed

[BUG] Invalid sequence name for PosgreSQL #1022

beermeat opened this issue Aug 7, 2013 · 8 comments

Comments

@beermeat
Copy link

beermeat commented Aug 7, 2013

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"

@dreamsxin
Copy link
Contributor

You are at the time of inserting data error?

@dreamsxin
Copy link
Contributor

I try fix it.

This was referenced Aug 8, 2013
@phalcon
Copy link
Collaborator

phalcon commented Aug 8, 2013

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

@dreamsxin
Copy link
Contributor

@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?

@phalcon
Copy link
Collaborator

phalcon commented Aug 8, 2013

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';
    }
}

@dreamsxin
Copy link
Contributor

@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";
    }
}

@dreamsxin
Copy link
Contributor

@sjinks How do you see
Best to specify the schema for PostgreSQL

@beermeat
Copy link
Author

beermeat commented Aug 8, 2013

@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.

phalcon pushed a commit that referenced this issue Aug 8, 2013
niden added a commit that referenced this issue Aug 15, 2013
@niden niden closed this as completed Aug 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants