-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expression in table columns is converted to literal column twice #617
Comments
I tried looking into this issue and found that there is this sqlalchemy method Will try and see the update of whether it can be directly used with help of sqlalchemy's |
After interacting with the Sqlalchemy issue support, #3737 - Bitbucket, I have implemented and tested the solution to escape the double percentage getting displayed for literal_column. This solution is basically a decorated method that takes care of removing back the added percentages for type of |
Met the same problem, hope the PR could be merged soon. |
Also notice 'week' and 'month' time grain is broken for SQLite because of this issue as well. Both have percent sign in its sql expression. 'sqlite': (
Grain('Time Column', _('Time Column'), '{col}'),
Grain('day', _('day'), 'DATE({col})'),
Grain("week", _('week'),
"DATE({col}, -strftime('%w', {col}) || ' days')"),
Grain("month", _('month'),
"DATE({col}, -strftime('%d', {col}) || ' days')"),
), |
If ddtm_expr is an expression with special characters then timestamp_grain escapes the special characters already escaped. Solution discussed with sqlalchemy upstream: https://bitbucket.org/zzzeek/sqlalchemy/issues/3737/literal_column-given-a-specific-sql Fix apache#617
If ddtm_expr is an expression with special characters then timestamp_grain escapes the special characters already escaped. Solution discussed with sqlalchemy upstream: https://bitbucket.org/zzzeek/sqlalchemy/issues/3737/literal_column-given-a-specific-sql Fix #617
If ddtm_expr is an expression with special characters then timestamp_grain escapes the special characters already escaped. Solution discussed with sqlalchemy upstream: https://bitbucket.org/zzzeek/sqlalchemy/issues/3737/literal_column-given-a-specific-sql Fix apache#617
As @yejianye pointed out this issue also breaks 'week' and 'month' time grains on SQLite but the fix that was applied only applies to column expressions, so I think that time grains are still broken for SQLite. |
@rhunwicks Time grains are still broken! Is there another bug report related to this? |
@vinay87 I'm not aware of another bug report - I think this one should be reopened. |
There's a bunch of tangled issues being discussed here, can someone open a new issue that explains exactly what is going on? I'm pretty sure the double |
@mistercrunch when you run a query against a SQLite database that has a time grain of week or month, you pass a {
'groupby': [],
'metrics': ['sum__value'],
'granularity': 'received',
'from_dttm': datetime.datetime(2001, 1, 1),
'to_dttm': datetime.datetime(2001, 12, 31),
'filter': [],
'is_timeseries': True,
'timeseries_limit': 50,
'timeseries_limit_metric': None,
'row_limit': 5000,
'extras': {
'time_grain_sqla': 'month',
},
'order_desc': True,
} The time grain code for SQLite uses The SQL that gets generated by that SELECT
DATE(received, -strftime('%%d', received) || ' days', '+1 day') AS __timestamp,
SUM(value) AS sum__value
FROM test_datasource
WHERE received >= '2001-01-01 00:00:00.000000' AND received <= '2001-12-31 00:00:00.000000' GROUP BY DATE(received, -strftime('%%d', received) || ' days', '+1 day')
ORDER BY sum__value DESC |
@mistercrunch can confirm this is still a problem, I hit it today. Will take a look. |
This should be fixed in SQLAlchemy 1.2: http://docs.sqlalchemy.org/en/latest/changelog/migration_12.html#percent-signs-in-literal-column-now-conditionally-escaped |
Bumps [lerna](https://github.com/lerna/lerna/tree/HEAD/core/lerna) from 3.22.0 to 3.22.1. - [Release notes](https://github.com/lerna/lerna/releases) - [Changelog](https://github.com/lerna/lerna/blob/master/core/lerna/CHANGELOG.md) - [Commits](https://github.com/lerna/lerna/commits/v3.22.1/core/lerna) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [lerna](https://github.com/lerna/lerna/tree/HEAD/core/lerna) from 3.22.0 to 3.22.1. - [Release notes](https://github.com/lerna/lerna/releases) - [Changelog](https://github.com/lerna/lerna/blob/master/core/lerna/CHANGELOG.md) - [Commits](https://github.com/lerna/lerna/commits/v3.22.1/core/lerna) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [lerna](https://github.com/lerna/lerna/tree/HEAD/core/lerna) from 3.22.0 to 3.22.1. - [Release notes](https://github.com/lerna/lerna/releases) - [Changelog](https://github.com/lerna/lerna/blob/master/core/lerna/CHANGELOG.md) - [Commits](https://github.com/lerna/lerna/commits/v3.22.1/core/lerna) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [lerna](https://github.com/lerna/lerna/tree/HEAD/core/lerna) from 3.22.0 to 3.22.1. - [Release notes](https://github.com/lerna/lerna/releases) - [Changelog](https://github.com/lerna/lerna/blob/master/core/lerna/CHANGELOG.md) - [Commits](https://github.com/lerna/lerna/commits/v3.22.1/core/lerna) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
if ddtm_expr is an expression with special characters then timestamp_grain escapes the special characters already escaped
models.py 660
Steps to reproduce:
Problem:
The text was updated successfully, but these errors were encountered: