f = lambda x: x.description.startswith("hibernate")
I have just defined an anonymous function in Python. I can then use it directly, without any further translation, on a Thing object:
class Thing(object):\n def __init__(self, description):\n self.description = description\n\nbear = Thing("hibernates in winter")
And f(bear) returns True without any intermediate magic. I hope you're not saying that calling a function is more than a programmer can handle. I will concede the fact that lambdas seem to mystify some people.
Given that simplicity, since functions are first-class objects in Python, I can pass that function down to a server like so:
hibernators = namespace.recall(Thing, f)
...and get back a list of all Thing objects for which the function f returns True.
Second point you might have missed: not every storage mechanism is going to be SQL-based. Some might be better off without persistence altogether. Some might be better off with a bsddb. So my solution is even more generic than a "generic SQL dialect".
Third, don't cheat. You wrote:
description.startswith("hibernate")
is much more cluttery than
like "hibernate%"
...conveniently leaving out the field name in your example to make it shorter. At the least, you should have written:
description.startswith("hibernate")
is much more cluttery than
description like "hibernate%"
I won't digress again into how UN-generic and cluttery "like" and "%" are. But I will note that new developers are far more likely to grok my Python syntax at first glance than your SQL.