Wrong where clause or a bug?

Wrong where clause or a bug?

markus-reichel@gmx.demarkus-reichel@gmx.de Posts: 4Questions: 2Answers: 0

Hello,

If I display the following table named "tabletest", I can edit lines as expected and they will be displayed correctly in the browser immediately after editing. This can also be seen in the returned data:
DT_RowId: "row_1"
DT_RowId: "row_2"
DT_RowId: "row_3"
Rows 1, 2, and 3 were edited and returned correctly.

{data: [{DT_RowId: "row_1", id: 1, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…},…],…}
data: [{DT_RowId: "row_1", id: 1, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…},…]
0: {DT_RowId: "row_1", id: 1, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
1: {DT_RowId: "row_2", id: 2, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
2: {DT_RowId: "row_3", id: 3, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
debug: [{query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}, {,…}, {,…},…]
0: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
1: {,…}
2: {,…}
3: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
4: {,…}
5: {,…}
6: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
7: {,…}
8: {,…}

When I select the same data with a nested Where condition, the "select" condition is displayed correctly in the browser.
In the following you can see the "select" condition as given in the tutorial:

$editor->where(function ($outer){
  $outer->where(function ($orBuilder) {
    $orBuilder->where('zuweisungtyp', 'Operator_MW')
               ->and_where('zuweisung', 'WebOEM');
  });

  $outer->or_where(function ($orBuilder) {
    $orBuilder->where('zuweisungtyp', 'Operator_OS')
              ->and_where('zuweisung', 'WebOEM');
  });

   $outer->or_where(function ($orBuilder) {
    $orBuilder->where('zuweisungtyp', 'TSO')
              ->and_where('zuweisung', '11111');
  });
});

but if i now change the same lines with the primary key 1,2 and 3, the data in the browser is not updated. Instead, the line with primary key 28 is updated (only in the view, not in the Database). But there nothing has changed at all.
The update command to the database is implemented correctly and the rows with the primary key 1,2 and 3 are updated. When I reload the page manually, the correct result is displayed.

{data: [{DT_RowId: "row_28", id: 28, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…},…],…}
data: [{DT_RowId: "row_28", id: 28, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…},…]
0: {DT_RowId: "row_28", id: 28, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
1: {DT_RowId: "row_28", id: 28, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
2: {DT_RowId: "row_28", id: 28, ip: "53.1.1.2", netzwerkzone: "p_app2", dns: "s03245645",…}
debug: [{query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}, {,…}, {,…},…]
0: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
query: "SELECT  id as "id" FROM  tabletest WHERE id = :where_0 "
bindings: [{name: ":where_0", value: "1", type: null}]
1: {,…}
2: {,…}
3: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
query: "SELECT  id as "id" FROM  tabletest WHERE id = :where_0 "
bindings: [{name: ":where_0", value: "2", type: null}]
4: {,…}
5: {,…}
6: {query: "SELECT id as "id" FROM tabletest WHERE id = :where_0 ",…}
query: "SELECT  id as "id" FROM  tabletest WHERE id = :where_0 "
bindings: [{name: ":where_0", value: "3", type: null}]
7: {,…}
8: {,…}

in my opinion the sql statement is correct:

query: "SELECT  id as "id", 
ip as "ip", 
netzwerkzone as "netzwerkzone", 
dns as "dns", 
zuweisungtyp as "zuweisungtyp", 
zuweisung as "zuweisung"
 
 FROM  tabletest
 
 WHERE (zuweisungtyp = :where_1 AND  zuweisung = :where_2 )
    OR (zuweisungtyp = :where_5 AND  zuweisung = :where_6 )
    OR (zuweisungtyp = :where_9 AND  zuweisung = :where_10 )"

I would expect instead of

0: {DT_RowId: "row_28
1: {DT_RowId: "row_28
2: {DT_RowId: "row_28

the return Value:

0: {DT_RowId: "row_1
1: {DT_RowId: "row_2
2: {DT_RowId: "row_3

if i do the same only with one where claus (respectively with no nested where clause) the update view works correct.

Answers

  • allanallan Posts: 64,042Questions: 1Answers: 10,557 Site admin

    Hi,

    How very odd. I'm afraid I can't put my finger on it. Can you give me a link to a page showing the issue so I can attempt to track it through please?

    Thanks,
    Allan

This discussion has been closed.