is it possible to do something like SELECT column1, column2 is null FROM table.. in DAL?

22 views
Skip to first unread message

Dragan Matic

unread,
Jun 21, 2023, 1:47:34 PM6/21/23
to web2py-users
Postgresql allows this syntax:

SELECT column1, column2 is null FROM table WHERE...

Which returns the value from column one and a true/false for column2 like this:

column1      column2
value1          true
value2          false

To summarize, I just want for database to tell me whether column2 is null or not, I do not want to read the whole column2 and check it in program as it may contain a lot of text and will slow down execution. Can I translate this select to DAL?

Massimiliano

unread,
Jun 21, 2023, 7:09:30 PM6/21/23
to web...@googlegroups.com
PyDal doen't implements is_null, but you can try something like that

t = db.yourtable
exp = "column2 is null"
print(db(t).select(t.column1, exp))


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b5d1573f-a5dc-4aad-8394-c2de75640cffn%40googlegroups.com.


--
Massimiliano
Reply all
Reply to author
Forward
0 new messages