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

Expand Query named binds recognition #4769

Conversation

paulbalandan
Copy link
Member

Description
Another pass to fixing named binds recognition by adding a negative lookahead for := types.

Fixes #4760 .
Supersedes and closes #4764

Checklist:

  • Securely signed commits
  • Unit testing, with >80% coverage
  • Conforms to style guide

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel qualified to assess the underlying issue and solution, but the code is fine.

@paulbalandan paulbalandan force-pushed the query-named-binds-recognition branch from 1ec2f3b to ed90ae5 Compare June 3, 2021 16:01
@paulbalandan paulbalandan merged commit a5fc431 into codeigniter4:develop Jun 4, 2021
@paulbalandan paulbalandan deleted the query-named-binds-recognition branch June 4, 2021 12:33
@vlakoff
Copy link
Contributor

vlakoff commented Aug 17, 2021

The outer parentheses are useless, so the code could be slightly simplified to:

preg_match('/:(?!=).+:/', $sql)

@paulbalandan
Copy link
Member Author

That's true, as we're not saving the matches. If you like, you can send a PR to simplify it.

@kenjis
Copy link
Member

kenjis commented Sep 23, 2021

This fix is very difficult to understand. Because the bug is related to Query Builder.

When $builder->where('id', 1), Query Builder creates a query like WHERE "id" = :id: inside.

When $builder->where('LOWER(jobs.name)', 'accountant'),
it creates WHERE LOWER(jobs.name) = :LOWER(jobs.name):.

And after all Query::compileBinds() binds the value.

Query Builder uses Named Bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Error using SQLITE3 strftime in CodeIgniter 4.1.2
5 participants