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

Improvement? Throw error when key parameter not found #177

Open
Zheness opened this issue Sep 27, 2019 · 1 comment
Open

Improvement? Throw error when key parameter not found #177

Zheness opened this issue Sep 27, 2019 · 1 comment

Comments

@Zheness
Copy link
Contributor

Zheness commented Sep 27, 2019

Hello !

I would like to know if it's possible to throw an error to indicates that a key has not been found in the parameter list ?

For example:

return $this->find('foo = :foo AND bar = :bar AND baz = :baz', [
    'foo' => 42,
    'baar' => 'Wrong key',
    'baz' => null
]);

In my code, I expect a key bar that is not provided, and would like to throw an error because my query will be wrongly executed if i mistype a parameter key.

I understand that when a value is null, it should work properly by removing the condition internally. But I expect that for not found key, it should not behave like that.

Is there any way to avoid the query to be executed if a key is missing ?

Thank you !

@moufmouf
Copy link
Member

This is an interesting idea but that would be a huge BC break (as people using the current API may rely on the fact that "a key is absent = a key is null")

This should actually be pushed down to the mouf/magic-query package. From there, we can add a "strict" option and we could add a "strict" mode in TDBM that uses magic-query strict mode.

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

No branches or pull requests

2 participants