Menu

#496 [MS SQL] 'no rows' when editing an entry where primary_key contains an underscore

Git
closed
nobody
None
5
2017-02-20
2016-05-09
cyberic
No

This happens with MSSQL.
function where($where, $fields = array()) {
...
$return[] = $column
. (($jush == "sql" && preg_match('~^[0-9]\.[0-9]$~', $val)) || $jush == "mssql"
? " LIKE " . q(addcslashes($val, "%_\")) <== HERE
: " = " . unconvert_field($fields[$key], q($val))
) // LIKE because of floats but slow with ints, in MS SQL because of text
; //! enum and set

the underscope has to be removed from the characters to escape, otherwise the query becomes:
'XXX where PK LIKE '%AA%_BB%'

You can see that the underscope is escapes, which isn't needed in MSSQL.

Hence, the select returns no row, and we cannot edit the entry.

Discussion

  • Jakub Vrána

    Jakub Vrána - 2017-02-20
    • summary: 'no rows' when editing an entry where primary_key contains an underscore --> [MS SQL] 'no rows' when editing an entry where primary_key contains an underscore
    • status: open --> pending-accepted
     
  • Jakub Vrána

    Jakub Vrána - 2017-02-20

    According to https://msdn.microsoft.com/en-us/library/ms179859.aspx, _ is a special character that needs escaping. However, there's no default escaping character so Adminer would need to specify one. Another problem is that [ is a special character too and Adminer should escape it as well.

    An alternative would be to use [_], [[] and similar without the ESCAPE clause.

     
  • Jakub Vrána

    Jakub Vrána - 2017-02-20
    • status: pending-accepted --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB