Changing smart_query to accept labels

21 views
Skip to first unread message

Carlos Costa

unread,
Apr 4, 2019, 11:41:23 AM4/4/19
to web2py-developers

Currently, the smart_query method only accepts table and field names.
The problem with that is when it is used on SQLFORM.grid search widget.
It is very strange for users to see, and they have no reference of the real field name to write in the input, 
because in the select fields, the label is displayed

I am experimenting with some changes in the smart_query for accepting field labels in the expression.

But I am not sure about the syntax, or even if it is viable to accept labels.
Because labels can have any type of characters, including spaces, this can lead to a "strange" string.

For example:
db.define_table('person', Field('first_name', label='First Name') )

Current syntax:
db.smart_query('person.first_name contains "car"')

A new optional syntax:
db.smart_query('person.first name contains "car"')

or 
db.smart_query('first name contains "car"')

or
db.smart_query('First Name contains "car"')

or the case that turns really ugly:
db.smart_query('person.First Name contains "car"')

Do you guys think this is too ugly to exist?
An alternative syntax to accept labels?

Everything I can imagine is not beautiful or user friendly enough.

db.smart_query('person[First Name] contains "car"')
db.smart_query('person."First Name" contains "car"')

Any ideas?
Reply all
Reply to author
Forward
0 new messages