Closed leejaywu closed 12 years ago
LIMIT and OFFSET clauses are not supported in SQL standard (at least the one I was working with when creating this framework, on http://savage.net.au/SQL/sql-99.bnf.html , and apparently it is not in 2003 either). Therefore they are not included in basic implementation. However, I will add support for LIMIT & OFFSET for MySQL soon.
Isn't the SQL:2008 standard keywords FETCH & OFFSET and LIMIT the one that was added by vendors? Plus the LIMIT syntax is not the same across the different databases that support LIMIT.
Supporting FETCH/OFFSET in DefaultVendor and add LIMIT implementations per vendor that support it would be a better bet IMA.
eskatos: Your suggestion sounds very good, I will take a look into 2008 standard and add support for these clauses. :)
+1 vote on getting this implemented :)
I've pushed the commits for this issue. I will mvn deploy the 0.3-SNAPSHOT in a few days, if no bugs are discovered. The methods for adding FETCH/OFFSET are in SimpleQueryBuilder and QuerySpecificationBuilder.
EDIT: Also notice the legacy switches in MySQLVendor and PostgreSQLVendor. I've added them for convenience.
Awesome Stan! ;-)
Closing this issue, since I've deployed the snapshot to public maven repo.
Seems odd that LIMIT would only be within the pgsql API, given that it's hardly the only database to support it -- e.g. MySQL has supported both LIMIT and OFFSET for years, and not having LIMIT support can result in some ridiculously inefficient queries.