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

DataTables w/ empty rows are rendered incorrectly when in DataTable Maps w/ other datatables #6206

Closed
diosmosis opened this issue Sep 13, 2014 · 9 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@diosmosis
Copy link
Member

DataTable\Map indexing sites like:

"1" => array(
    array( // first and only row
        'nb_visits' => 1
    )
),
"2" => array(
    array() // no rows
)

renders to: {"1": 1, "2": []}

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Sep 14, 2014
@mattab mattab modified the milestones: Mid term, Short term Sep 14, 2014
@tsteur
Copy link
Member

tsteur commented Feb 4, 2015

FYI: to reproduce I am using this code in an API.php

    public function test()
    {
        $map = new DataTable\Map();
        $table = DataTable::makeFromIndexedArray(array('nb_visits' => '1'));
        $map->addTable($table, '1');
        $map->addTable(new DataTable(), '2');

        return $map;
    }

This returns

with JSON format
{"1":[{"label":"nb_visits","value":"1"}],"2":[]}

with PHP format
array (
  1 => 
  array (
    0 => 
    array (
      'label' => 'nb_visits',
      'value' => '1',
    ),
  ),
  2 => 
  array (
  ),
)

Was it maybe fixed recently? Or maybe I did not understand it?

@diosmosis
Copy link
Member Author

Does it do that w/o the 'label' column?

@tsteur
Copy link
Member

tsteur commented Feb 4, 2015

I'm not sure what you mean?

@diosmosis
Copy link
Member Author

Your example has a 'label' column + the 'nb_visits' one, but the one I posted (a while ago) only has one column ('nb_visits'). That's probably what triggered the bug for me, but can't remember.

@tsteur
Copy link
Member

tsteur commented Feb 4, 2015

Using this code

    public function test()
    {
        $map = new DataTable\Map();

        $row   = new Row(array(Row::COLUMNS => array('nb_visits' => '1')));
        $table = new DataTable();
        $table->addRow($row);
        $map->addTable($table, '1');

        $map->addTable(new DataTable(), '2');

        return $map;
    }

results in

{"1":[{"nb_visits":"1"}],"2":[]}

and


array (
  1 => 
  array (
    0 => 
    array (
      'label' => 'nb_visits',
      'value' => '1',
    ),
  ),
  2 => 
  array (
  ),
)

@diosmosis diosmosis self-assigned this Feb 4, 2015
@diosmosis
Copy link
Member Author

Maybe it was fixed, I'll explore when I'm able.

@tsteur
Copy link
Member

tsteur commented Feb 5, 2015

OK. Probably the issue still exist but need the right structure

@mattab mattab modified the milestones: Mid term, Short term Apr 8, 2015
@diosmosis diosmosis removed their assignment Apr 29, 2015
@mattab
Copy link
Member

mattab commented Sep 11, 2015

@diosmosis is it something we should care about in 3.0.0? if yes, please move it there

@diosmosis
Copy link
Member Author

Can no longer reproduce.

@mattab mattab added the worksforme The issue cannot be reproduced and things work as intended. label Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

3 participants