ok. there's clearly a mismatch between what you expect from what you're 
writing.....

db.table.field == 'something'
db.table.field > something
db.table.field.startswith('something')
db.table.field.contains('something')

are what in DAL are called Queries. 
They turn out to be the "WHERE" part in T-SQL.
DAL (with an exception on the belongs() method) expects the 'something' to 
be fixed.

Now, you want your relationship defined out of a relation that in T-SQL 
isn't really performant ( startswith turns into a LIKE statement that 
basically needs to scan the entire table).
I'd advise you to simply add to the equipment table a reference to the 
models... queries are much faster that way (both writing them and execution 
times on the backend).

"my data model"
db.define_table("models", Field("name"), Field("expected_life", "integer"))
db.define_table("equipment", Field("model_id", "reference models"), Field(
"name"))
#fetch all equipments with 10 years of expected life
db(db.models.expected_life == 10)(db.equipment.model_id == db.models.id).
select(db.equipment.ALL)

Assuming you want to pursue your model, and assuming that is roughly

db.define_table("models", Field("name"), Field("expected_life", "integer"))
db.define_table("equipment", Field("name"))


what you need instead is to basically fetch all models and do something 
like name.startswith(first_result) OR name.startswith(second_result) OR ....

#fetch all models with 10 years of expected life
models_10 = db(db.models.expected_life == 10).select() ##holds SVP7 and such
queries = [db.equipment.name.startswith(row.name) for row in models_10]
#now, let's put them in a OR ... OR fashion
query = reduce(lambda a,b: (a|b), queries)
#finally, fetch the equipments
equipments_10 = db(query).select()



-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to