On Thursday, December 20, 2012 9:34:31 AM UTC-8, James wrote:
>
> On occasion I use Sequel with a PSQL database (using ODBC), which doesn't
> support LIMIT. What's the simplest way to add "TOP 10" to a dataset
> without reverting to writing the full SQL query string?
You probably want to modify the datasets for the database so that they use
TOP instead of LIMIT. Then you can just add .limit(10) to the dataset.
This might work:
DB.extend_datasets do
SELECT_CLAUSE_METHODS = Sequel::Dataset.clause_methods(:select, %w'select
limit distinct columns from join where group having compounds order lock')
TOP = " TOP "
def select_clause_methods
SELECT_CLAUSE_METHODS
end
def select_limit_sql(sql)
if l = opts[:limit]
sql << TOP
literal_append(sql, l)
end
end
end
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/F8GS_QDEVH0J.
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/sequel-talk?hl=en.