Skip to content

PostgreSQL fActiveRecord::populate sets auto_increment field to 0 as default #216

@kwarunek

Description

@kwarunek

PostgreSQL definiton:

    some_id bigint NOT NULL DEFAULT nextval('seq_some_id'::regclass),

Flourish column's info:

Array (
    [type] => integer
    [min_value] => fNumber Object
        (
            [scale:fNumber:private] => 0
            [value:fNumber:private] => -9223372036854775808
        )
    [max_value] => fNumber Object
        (
            [scale:fNumber:private] => 0
            [value:fNumber:private] => +9223372036854775807
        )
    [auto_increment] => 1
    [not_null] => 1
    [comment] => 
    [placeholder] => %i
    [default] => 
    [valid_values] => 
    [max_length] => 
    [decimal_places] => 
)

As you can see default is not set https://github.com/flourishlib/flourish-classes/blob/master/fSchema.php#L1758.

fActiveDirectory::populate sets auto increment field to 0 (note: this field is not in request, of'course). This prevents fActiveDirectory::store to success on insert new row., 'cause it doesn't meet condition value === NULL

As flourish is deprecated library and it is abandoned, I won't provide PR - it wouldn't be merged. Simple workaround replace line:

    if ($schema->getColumnInfo($table, $column, 'auto_increment') && $schema->getColumnInfo($table, $column, 'not_null') && $this->values[$column] === NULL) {

with:

    if ($schema->getColumnInfo($table, $column, 'auto_increment') && $schema->getColumnInfo($table, $column, 'not_null') && !$this->values[$column]) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions