Re: [Modeling-users] API cleanup proposal
Status: Abandoned
Brought to you by:
sbigaret
|
From: Jerome K. <Jer...@fi...> - 2003-07-02 09:22:39
|
Mario Ruggier wrote:
Hum .. A general note about aliasing methods: In fact
I use a couple of tools for test (SQLObject / MiddleKit/
and Modeling) so as MiddleKit and Modeling try to
monkey EOF, it use the same method names like
insertObject() .. so for me staying closer to EOF is a good
thing .
>> - make fetchCount() an alias for objectsCountWithFetchSpecification()
>> [same API as fetch()]
>
>
> Hmmn, I would not introduce such a specialized method (will become
> clutter even in the short term). As suggested earlier, it may be more
> flexible to just have a fetchSql() open method for now (that is not
> necessarily db-independent) and that returns whatever the dbapi
> returns. For me nothing is gained by having fetchCount('customobjname')
> over fetchSql('select count(*) from tblname') -- it is jn fact less
> flexibe.
> When the time comes to generailize this to be db-independant, either
> the fetch() method will gain new parameters to allow this, or other
> generic methods introduced, such as fetchRaw, fetchTuples, fetchDicts,
> or whatever. fetchSql can always have a use, though, so it it not likely
> to become clutter.
I guess you miss something Mario.
Let's take a example .
qualifier=qualifierWithQualifierFormat('lastName=="Hugo"')
fetchSpec=FetchSpecification(entityName='Writer', qualifier=qualifier)
fetchCount(fetchSpec) will return the number of writer with lastname =
'Hugo' ..
and so on this is not so trivial as a simple 'select count(*) ..'
so the answer is no : fetchCount() and fetchSql() haven't the same
purpose, even
is you can use fetSQL to do a fetchCount() or anything else.
And i really like the OO approach of modeling, and i really think that
even fetchSQL() ( which for me should be fetchSQLObject() ) should
alway return a object.
Take a look at this:
- in the model you describe the object mapping (which is not a real object
but only a "result object" .
for example:
CustomSearch
- searchString()
- books relation one-> many
- ...
- I thinks we should find a way to do
ec.objectsWithFetchSpecification('CustomSearch, ..searchString = 'Toto') ..
and so provide a method to do some special SQL in the CustomSearch() which
return CustomSearch object.
But this way you can do something like
search = CustomSearch(...)
books = search.getBooks() ( which return some books object .. not raw SQL)
>> Future enhancements
>> -------------------
>>
>> Interesting future features (NOT included in this proposal) have been
>> proposed in this thread, including:
>>
>> - fetchSQL(): the possibility to pass a raw sql query to build
>> objects,
>
To build Objects or raw SQL ?
Perhaps we can take a look on how SQLObject do that ?
>>
>> - the ability to fetch raw rows (i.e. raw dict) rather than
>> fully-initialized objects,
>>
yeah ..
Bye Bye ..
|