Skip to content

Use proper sql parser #123

Open
Open

Activity

  1. craigfrancis commented on Jan 17, 2022

    @craigfrancis
    Contributor

    Might be worth looking at the PDO function that parses parameters, to see how it works.

    It seems to use pdo_parse_params(), which is a bit more complicated than using the BINDCHR regex by itself (used later as PDO_PARSER_BIND).

    It supports escaped question marks (??), comments (/* What about X? */ or -- To fix?), and quoted string values (see ANYNOEOF?).

  2. staabm commented on Jan 17, 2022

    @staabm
    OwnerAuthor

    Would be great if you could provide failling testcases if you have special cases in mind

  3. craigfrancis commented on Jan 17, 2022

    @craigfrancis
    Contributor

    I don't have any real examples, but how about?

    • SELECT * FROM cmsdomain WHERE url LIKE "%?%";
    • SELECT * FROM cmsdomain WHERE url LIKE "%:tag_name%";
    • SELECT * FROM cmsdomain WHERE cmsdomainid IN (1,2) /* What about 3? */
    • SELECT * FROM cmsdomain WHERE 1=2; -- :TODO?
  4. staabm commented on Jan 19, 2022

    @staabm
    OwnerAuthor

    I don't have any real examples, but how about?

    * `SELECT * FROM cmsdomain WHERE url LIKE "%?%";`
    
    * `SELECT * FROM cmsdomain WHERE url LIKE "%:tag_name%";`
    
    * `SELECT * FROM cmsdomain WHERE cmsdomainid IN (1,2) /* What about 3? */`
    
    * `SELECT * FROM cmsdomain WHERE 1=2; -- :TODO?`
    

    these basic examples are now covered by #145

    still on the long run we might better use a sql parser. lets see whether people report problems with their queries when running phpstan-dba on real projects

  5. added
    enhancement
    on Jan 30, 2022
  6. staabm commented on Aug 26, 2022

    @staabm
    OwnerAuthor

    on twitter the SQLFTW/sqlftw project was suggested as a proper parser

  7. added this to the SQL AST milestone on Nov 11, 2022
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

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions