Menu

#494 Update single registry in a view generates a huge WHERE clause

4.2.0
closed-rejected
nobody
5
2017-02-20
2016-04-15
Marcelo
No

When you UPDATE a single registry in a TABLE, the WHERE clause just takes the ID. Thats OK.

When you try doing the same in a VIEW, the generated WHERE takes ALL fields and became a giant filter expression, even when the view contains the ID field and uses just ONE table.

Any Ideias of how I can FORCE the generated WHERE to take just the ID likewise is done with tables? This is critical to our project.

Discussion

  • Marcelo

    Marcelo - 2016-04-24

    The solution:

    Since the VIEW doesn't have indexes, the workaround was compel primary key as the unique identifier by enforcing conventions. The unique_array() function was changed, so that, if no PRIMARY index has found, the ID field is assumed to be that. It's safe, because if no ID is found, the original code remains the same.

    In functions.inc.php, line 386, insert these 2 lines, right before the unique_array() closing bracket:
    if (isset($row['id'])) { return array('id' => $row['id']);}
    if (isset($row['ID'])) { return array('ID' => $row['ID']);}

     
  • Jakub Vrána

    Jakub Vrána - 2017-02-20
    • status: open --> closed-rejected
     
  • Jakub Vrána

    Jakub Vrána - 2017-02-20

    There's no information about unique fields in indexes so Adminer couldn't use them.

     

Log in to post a comment.

MongoDB Logo MongoDB