PostgreSQL migrations - default values in double quotes #859

Closed
radeczo opened this Issue Sep 27, 2016 · 1 comment

Projects

None yet

2 participants

@radeczo
Contributor
radeczo commented Sep 27, 2016 edited

Hi.

Phalcon DevTools (3.0.0)

Default values in PostgreSQL should be in single quotes (for strings) or as an number (for int, bigint, etc.). Double quoted values Postgres interprets as column names.

Error example:

Column definition:

new Column(
    'status',
    [
        'type' => Column::TYPE_INTEGER,
        'default' => "1",
        'after' => 'order'
    ]
),

Generated SQL:

CREATE TABLE "public"."table" (
    ...
    "status" INT DEFAULT "1",
    ...
);

Postgres error:
ERROR: SQLSTATE[42703]: Undefined column: 7 ERROR: column "1" does not exist

@sergeyklay
Collaborator

@radeczo

I've fixed this issue in the Phalcon 3.0.x branch. You need to update Phalcon:

git clone git@github.com:phalcon/cphalcon.git
cd cphalcon
git checkout 3.0.x

zephir fullclean
zephir build

Thank you for contributing!

@sergeyklay sergeyklay closed this Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment