Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Informix versions < 10 use 'FIRST' keyword instead of 'LIMIT' #167

Merged
merged 1 commit into from

3 participants

@pparidans

Informix Versions <= 9 use the 'FIRST' keyword to limit the number of records returned.
Version 10 introduced the 'LIMIT' keyword as an alias.
As far as I know, upper versions still support 'FIRST' (at least until v11).

@tamird

@pparidans can you rebase this please?

@tamird

LGTM @rafaelfranca can we merge this?

@rafaelfranca rafaelfranca merged commit fe7d2af into rails:master

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 16, 2014
  1. @pparidans

    Informix versions < 10 use 'FIRST' keyword instead of 'LIMIT'

    pparidans authored pparidans committed
    Still supported in versions 10+
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +1 −1  lib/arel/visitors/informix.rb
  2. +6 −6 test/visitors/test_informix.rb
View
2  lib/arel/visitors/informix.rb
@@ -41,7 +41,7 @@ def visit_Arel_Nodes_Offset o, collector
visit o.expr, collector
end
def visit_Arel_Nodes_Limit o, collector
- collector << "LIMIT "
+ collector << "FIRST "
visit o.expr, collector
collector << " "
end
View
12 test/visitors/test_informix.rb
@@ -11,21 +11,21 @@ def compile node
@visitor.accept(node, Collectors::SQLString.new).value
end
- it 'uses LIMIT n to limit results' do
+ it 'uses FIRST n to limit results' do
stmt = Nodes::SelectStatement.new
stmt.limit = Nodes::Limit.new(1)
sql = compile(stmt)
- sql.must_be_like "SELECT LIMIT 1"
+ sql.must_be_like "SELECT FIRST 1"
end
- it 'uses LIMIT n in updates with a limit' do
+ it 'uses FIRST n in updates with a limit' do
table = Table.new(:users)
stmt = Nodes::UpdateStatement.new
stmt.relation = table
stmt.limit = Nodes::Limit.new(Nodes.build_quoted(1))
stmt.key = table[:id]
sql = compile(stmt)
- sql.must_be_like "UPDATE \"users\" WHERE \"users\".\"id\" IN (SELECT LIMIT 1 \"users\".\"id\" FROM \"users\")"
+ sql.must_be_like "UPDATE \"users\" WHERE \"users\".\"id\" IN (SELECT FIRST 1 \"users\".\"id\" FROM \"users\")"
end
it 'uses SKIP n to jump results' do
@@ -35,12 +35,12 @@ def compile node
sql.must_be_like "SELECT SKIP 10"
end
- it 'uses SKIP before LIMIT' do
+ it 'uses SKIP before FIRST' do
stmt = Nodes::SelectStatement.new
stmt.limit = Nodes::Limit.new(1)
stmt.offset = Nodes::Offset.new(1)
sql = compile(stmt)
- sql.must_be_like "SELECT SKIP 1 LIMIT 1"
+ sql.must_be_like "SELECT SKIP 1 FIRST 1"
end
it 'uses INNER JOIN to perform joins' do
Something went wrong with that request. Please try again.