Sql Server - No Limits
I've been playing around with the Ajax Scaffold recently.
Because of the trouble I've been having with scrptxfr (meaning that Rails cannot copy my dev database structure to my test database) I've been working in MySql and relying on migrations to move over to Sql Server when I'm done.
But I've hit a problem. Ajax Scaffold uses pagination all over the shop. Pagination needs to be able to ask for records 20 to 30 out of a particular dataset. This is easy in MySql - just use the limit clause, specifying the record numbers that you want. It's not easy in Sql Server. Sql Server offers you top so you can grab the first 30 records. But nowhere does it offer you a filter returning record 20 to record 30. So the SqlServerAdapter tries to fake it - it does (select top 10 * from (select top 30 from table order by id desc) order by id asc) - (I may have got my ascs and descs the wrong way round). This works. It's nasty but it works. Until you use an :include or an :order. Then it just falls over in a crumpled heap. Whimpering.
The only way around it that I can think of is to hack the SqlServerAdapter so that it does a select top 30 * from table, disconnect the recordset (it's only ADO after all) and then delete the first 20 rows. Not nice eh?
4 comments:
Sounds like it might be related to this bug.
Cheers - looks like the one. I'll give it a go.
Personal service too. Nice!
you could try using the RowNumber function in sql 2005 to get what you want
I'm still on Sql 2000. None of this new-fangled technology for me Anthony.
Post a Comment