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

query for columns that are not null #109

Open
brachetti opened this issue Oct 20, 2015 · 8 comments
Open

query for columns that are not null #109

brachetti opened this issue Oct 20, 2015 · 8 comments

Comments

@brachetti
Copy link

What would be a good way to query for a column that IS NOT NULL?
From reading the code I can see no way to do that.

While waiting for an answer I will prepare a PR how I would do it.

Cheers! :-)

@vbarbarosh
Copy link

Hi,

Did you tried $db->table()->where('column_name IS NOT NULL')?

@brachetti
Copy link
Author

That actually seems to work, judging from the tests. I'm not entirely sure, why, though ...

Since the code I have to maintain works very extensively with arrays, I would like to explicitly add where("column", "is not null") ... what do you think?

brachetti added a commit to brachetti/notorm that referenced this issue Oct 20, 2015
…rana#109)

Also included explicit test for previously working "column is not null" where option
@vbarbarosh
Copy link

How then you distinct when column contains string "IS NOT NULL" and column literally IS NOT NULL?

@brachetti
Copy link
Author

That's a good point you make there. Intuitively I would answer that with $table->where($col, "'IS NOT NULL'"); but it's not really ideal considering backwards compatibility ... do you have a suggestion using the array syntax?

@vbarbarosh
Copy link

Just a quick thought: $db->table()->where($col, new IsNotNull()). Then at the place where is implemented check its second argument for instanceof IsNotNull.

@WooterTheTroubleshooter

Hi,

This might work:

$db->table()->where("NOT $column", null);

On Tue, Oct 20, 2015 at 8:29 PM, Vladimir Barbarosh <
[email protected]> wrote:

Just a quick thought: $db->table()->where($col, new IsNotNull()). Then at
the place where is implemented check its second argument for instanceof
IsNotNull.


Reply to this email directly or view it on GitHub
#109 (comment).

@vbarbarosh
Copy link

Right from the docs. )

$table->where("NOT field", array("x", "y"))
Translated to NOT field IN ('x', 'y') (with automatic escaping)

@brachetti
Copy link
Author

So I guess it would be better to remove the new code in Result.php and just add more tests.
I also think that the documentation could be enhanced in that regard. Is there a repository where I could do that, which I missed?

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

No branches or pull requests

3 participants