Skip to content

Sql Metric Expression which uses % has % duped in tableView query #274

Closed

Description

@scophotog

I created a sql metric with the expression:

CAST(strftime("%s", max("timestamp")) AS INT)

When I used this metric to create a table view the values were not being populated. Looking into the JSON I found the query had duplicated the %:

query: "SELECT "serviceName" AS "serviceName", CAST(strftime("%%s", max("timestamp")) AS INT)
 AS latest_date FROM "testResults" WHERE timestamp >= '2016-03-29 15:57:43.000000' AND timestamp <= '2016-04-05 15:57:43.000000' GROUP BY "serviceName" ORDER BY 
CAST(strftime("%%s", max("timestamp")) AS INT) DESC LIMIT 50000 OFFSET 0"

Current end result is this column ends up displaying a 0 for each entry

Activity

  1. kingo55 commented on Apr 6, 2016

    @kingo55
    Contributor

    Does it need escaping? It's weird it's returning the quote marks unescaped too.

  2. scophotog commented on Apr 6, 2016

    @scophotog
    Author

    I did try escaping around the % and the " characters surrounding the %s but I'm still getting the % duplicated.

    query: "SELECT CAST(strftime("/_%%s", max("timestamp")) AS INT) AS latest_date FROM "testResults" WHERE timestamp >= '2016-03-30 08:36:01.000000' AND timestamp <= '2016-04-06 08:36:01.000000' LIMIT 50000 OFFSET 0"
    
    query: "SELECT CAST(strftime("\%%s", max("timestamp")) AS INT) AS latest_date FROM "testResults" WHERE timestamp >= '2016-03-30 08:36:01.000000' AND timestamp <= '2016-04-06 08:36:01.000000' LIMIT 50000 OFFSET 0"
    
  3. mistercrunch commented on Apr 7, 2016

    @mistercrunch
    Member

    Have you tried doubling the % as in %%? I think we had this bug before but forgot about the details/workaround.

  4. mistercrunch commented on Apr 7, 2016

    @mistercrunch
    Member

    Also which DB / sqlalchemy dialect are you using?

  5. scophotog commented on Apr 7, 2016

    @scophotog
    Author

    Have you tried doubling the % as in %%? I think we had this bug before but forgot about the details/workaround.

    I'll give that a shot.

    Also which DB / sqlalchemy dialect are you using?

    I'm using sqllite3.

  6. scophotog commented on Apr 7, 2016

    @scophotog
    Author

    Have you tried doubling the % as in %%? I think we had this bug before but forgot about the details/workaround.

    I'll give that a shot.

    It appears to make more % characters

    query: "SELECT "serviceName" AS "serviceName", CAST(strftime("%%%%s", max("timestamp")) AS INT) AS latest_date FROM "testResults" WHERE timestamp >= '2016-03-31 11:20:59.000000' AND timestamp <= '2016-04-07 11:20:59.000000' GROUP BY "serviceName" ORDER BY CAST(strftime("%%%%s", max("timestamp")) AS INT) DESC LIMIT 50000 OFFSET 0"
    
  7. added
    !deprecated-label:bug
    on Aug 9, 2016
  8. mtkage commented on Dec 29, 2016

    @mtkage

    Is there a workaround for this problem?

  9. ratb3rt commented on Mar 8, 2017

    @ratb3rt

    This seems refers to a SQLAlchemy bug, which should be fixed in v1.2. It's patched for DateTimes in models.py :Patch for sqlalchemy bug
    Bug ref: https://bitbucket.org/zzzeek/sqlalchemy/issues/3740/clean-up-doubling-of-percent-signs-base-on

  10. mistercrunch commented on Mar 8, 2017

    @mistercrunch
    Member

    in #2330 I started doubling the % in the WHERE clause and in the new LIKE clause of filters.

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

    !deprecated-label:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions