[BUG] DBResultSet>>#collect:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] DBResultSet>>#collect:

Richard A. Harmon
Dolphin 4.0 is terrific.  Really like the new Education Centre.  Great
job.

While trying out the tutorial on ODBC:

c := (DBConnection new)
        dsn: 'NWind';
        uid: 'Tony';
        pwd: 'alpha';
        connect.
rs := c query: 'select * from Orders'.
rs collect: [:x | x ShipName].

signals a <MessageNotUnderstood> exception for Array>>#addLast:.



DBResultSet >> collect: transformer
        "Evaluate the <monadicValuable> argument, transformer, for
each of the receiver's elements in the order defined by the receiver's
implementation of #do:.
        Answer a new collection like the receiver containing the
values returned by transformer on each evaluation.
        Implementation Note: Override back to Collection
implementation because superclass implementation needs exact #size,
which can be slow against DBResultSets."
        | answer |
        answer := self copyEmpty.
        self do: [:elem | answer addLast: (transformer value: elem)].
        ^answer

Either of the following works.  The OrderedCollection fix is slightly
faster but the WriteStream fix answers a result of the receiver's
species.

        | answer |
        answer := OrderedCollection new: self approxSize.
        self do: [:elem | answer addLast: (transformer value: elem)].
        ^answer

        | ansStrm |
        ansStrm := WriteStream with: (self species new).
        self do: [:elem | ansStrm nextPut: (transformer value: elem)].
        ^ansStrm contents


--
Richard A. Harmon          "The only good zombie is a dead zombie"
[hidden email]           E. G. McCarthy


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] DBResultSet>>#collect:

Blair McGlashan
Richard

You wrote in message news:[hidden email]...

>
>
> Dolphin 4.0 is terrific.  Really like the new Education Centre.  Great
> job.
>
> While trying out the tutorial on ODBC:
>
> c := (DBConnection new)
>         dsn: 'NWind';
>         uid: 'Tony';
>         pwd: 'alpha';
>         connect.
> rs := c query: 'select * from Orders'.
> rs collect: [:x | x ShipName].
>
> signals a <MessageNotUnderstood> exception for Array>>#addLast:.
>
>
>
> DBResultSet >> collect: transformer

Thanks for the plaudits and the bug report.

This problem with DBResultSet>>collect: is a known bug (badly patched in
SP1). It is fixed in 4.01 (defect no. 19 it seems) along with over 100 other
bug fixes and enhancements. We hope to release it shortly as a free update
for 4.0 users, but are working on an Education Centre update to accompany
it.

Regards

Blair