Skip to content
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

Paginator QueryBuilder not escaping rowcount column #12950

Closed
dnapierata opened this issue Jul 10, 2017 · 4 comments
Closed

Paginator QueryBuilder not escaping rowcount column #12950

dnapierata opened this issue Jul 10, 2017 · 4 comments
Labels
bug A bug report status: medium Medium
Milestone

Comments

@dnapierata
Copy link
Contributor

dnapierata commented Jul 10, 2017

Expected and Actual Behavior

When using the paginator with a GROUP BY and HAVING clause, the sql that is generated does not escape the aliased column and thus I am receiving a syntax error from my database (MSSQL 12.0). https://github.com/phalcon/cphalcon/blob/master/phalcon/paginator/adapter/querybuilder.zep#L228

I would expect Line 228 to be

let row = db->fetchOne("SELECT COUNT(*) as \"rowcount\" FROM (" .  sql["sql"] . ") as T1", Db::FETCH_ASSOC, sql["bind"]),

Details

  • Phalcon version: (3.2.0)
  • PHP Version: ( 7.0.18-0ubuntu0.16.04.1)
  • Operating System: Linux
  • Installation type: installing via package manager
  • Server: Apache
  • Other related info (Database, table schema): MSSQL 12.0
@sergeyklay
Copy link
Contributor

sergeyklay commented Jul 10, 2017

Phalcon does not have build-in MSSQL dialect class. So most likely this is a new feature request for Incubator but not a Phalcon bug.

@sergeyklay sergeyklay added the not a bug Reported issue is not a bug label Jul 10, 2017
@dnapierata
Copy link
Contributor Author

I realize MSSQL isn't currently supported by phalcon but this fix is just to make the generated SQL more standards compliant and in fact it is already being done here https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model.zep#L1135

I already have the dialect and adapter classes for sql server but this does not solve the issue I have posted above. I am just asking you add double quotes around rowcount so that the query builder paginator is more compatible with future db dialects.

@sergeyklay sergeyklay added New Feature Request and removed not a bug Reported issue is not a bug labels Jul 10, 2017
@sergeyklay sergeyklay reopened this Jul 10, 2017
@Jurigag
Copy link
Contributor

Jurigag commented Jul 10, 2017

Can you do PR with fix to 3.2.x branch?

@dnapierata dnapierata mentioned this issue Jul 10, 2017
3 tasks
@sergeyklay
Copy link
Contributor

Fixed in the 3.2.x branch. Feel free to open a new issue if the problem appears again. Thank you for contributing.

@sergeyklay sergeyklay modified the milestones: unplanned, 3.2.x Jul 19, 2017
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

4 participants