I have a problem with datamapper loading associated data with all but
small amounts of data.

Simplified example:

Model Booking, has one Staff

Find all the bookings for this week, get about 6000

Iterate through bookings and get the associated staff

Error from SQL Server:

*Prepared or callable statement has more than 2000 parameter markers.*

This is because there are about 3000 individual staff associated with
those 6000 bookings. Datamapper tries to be clever and select them all
in one go with a "where staff_id in (.....)" and the in clause has
3000 values!

This is not a problem with having 3000 values in there, but datamapper
tries to use a statement with parameters and that's what SQL Server
doesn't like.

Selecting them all in one go is better than 3000 individual selects,
but not if it doesn't work at all.

I can certainly work around this case by iterating over the bookings,
pulling out the staff_id and constructing my own select statement with
the 3000 values. However, I then lose the nice booking.staff
usefulness and it's a lot more work.

Is there a way I can tell datamapper to use a join when selecting the
bookings, a bit like ARs :include option?

Is there any other trick I have missed to make this work with anything
other than small amounts of data?

Cheers,
Gary.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to