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

Error: PostgresSQL create table default value for integer column #12267

Closed
Ridlsan opened this issue Sep 29, 2016 · 2 comments
Closed

Error: PostgresSQL create table default value for integer column #12267

Ridlsan opened this issue Sep 29, 2016 · 2 comments
Assignees
Labels
bug A bug report status: medium Medium
Milestone

Comments

@Ridlsan
Copy link

Ridlsan commented Sep 29, 2016

Phalcon 3.0.1

If setting default value 0 for integer column, phalcon escapes it as string and postgres complains as column "0" not exists.

Change its behavior in https://github.com/phalcon/cphalcon/blob/master/phalcon/db/dialect/postgresql.zep#L382

Just add check - if INTEGER so not escape value. Phalcon already has check for BOOLEAN

        if column->hasDefault() {
                let defaultValue = column->getDefault();
                if memstr(strtoupper(columnDefinition), "BOOLEAN") {
                    let sql .= " DEFAULT " . (defaultValue ? "true" : "false");
                } elseif memstr(strtoupper(defaultValue), "CURRENT_TIMESTAMP") {
                    let columnLine .= " DEFAULT CURRENT_TIMESTAMP";
                } else {
                    let columnLine .= " DEFAULT \"" . addcslashes(defaultValue, "\"") . "\"";
                }
        }
@sergeyklay sergeyklay added this to the 3.0.2 milestone Sep 29, 2016
@sergeyklay sergeyklay self-assigned this Sep 29, 2016
@sergeyklay
Copy link
Contributor

Refs: phalcon/phalcon-devtools#859
I'll fix it ASAP.

@sergeyklay
Copy link
Contributor

sergeyklay commented Sep 30, 2016

Fixed. You have to update Phalcon from the 3.0.x branch:

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

zephir fullclean
zephir build

Thank you for contributing!

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants