Proposal: Database Engine for D
Marc Schütz via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jan 6 06:09:17 PST 2016
On Tuesday, 5 January 2016 at 22:12:05 UTC, Mengu wrote:
> but as a web developer, i don't mind if i have to type
> User.where("first_name = ? AND age > 27",
> request.POST.get('name')). this will generate the same query
> above. i added the question mark to say the parameters should
> be escaped properly.
As a web developer, I _do_ care, though. For one, I shouldn't
have to know how the fields are called in the database. But more
importantly, it isn't composable: in the general case, you can
not write e.g.
User.joins("other_table ON ...").where("first_name = ? ...");
and expect it to work, because `first_name` could be ambiguous.
This in turn means that you can't create abstractions, for
example:
auto users = User
.onlyMale
.where(["birthday": Date.today])
.orderBy!(User.firstName);
Here your query would have to know how male and female users are
represented in your database, e.g. by an integer, a lowercase
'm', an uppercase 'M'... Such lack of abstraction can quickly
make your codebase unmaintainable.
More information about the Digitalmars-d
mailing list