Skip to content

Additional space in a parameter which is a string (mysql)  #955

Description

@nowackipawel

During my tests I noticed sth what should not happened I noticed that i've values are around 2 time lower than they should:
$this->select('ROUND(100*AVG(IFNULL(t_apk_game2users.agu_ok, 0))/AVG(LENGTH(aga_questions) - LENGTH( REPLACE ( aga_questions, ",", "")) +1)) agu_avg_ok')->...
but it produces query with additional space inside replace:
ROUND(100*AVG(IFNULL(t_apk_game2users.agu_ok, 0))/AVG(LENGTH(aga_questions) - LENGTH( REPLACE ( aga_questions, here-->", "<--here, "")) +1))

aga_questions is varchar which stores json_encode of int[]
agu_ok is TINYINT column

So as for now I had to change my query to get real results:
ROUND(100*AVG(IFNULL(t_apk_game2users.agu_ok, 0))/AVG((LENGTH(aga_questions) - LENGTH( REPLACE ( aga_questions, ", ", "")) +2)/2))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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