jruby/activerecord-jdbc-adapter — pull request #371 by jamuc (2013-04-11 16:28:20+00:00)
Title: Offset can also be of type Arel::Node::Offset

# Description
---------------------------------------------------------------------------------

We're currently using an H2 database in a JRuby/TorqueBox deployment. We've implemented a backp/restore feature based on [yaml_db](https://github.com/ludicast/yaml_db).

The [SerializationHelper](https://github.com/ludicast/yaml_db/blob/master/lib/serialization_helper.rb) creates a SQL query using the Arel interface:
```query = Arel::Table.new(table).order(id).skip(records_per_page*page).take(records_per_page).project(Arel.sql('*'))```

The Table.new(table)#skip method is supposed to create an offset value. This does not work properly, since the generated offset can be of type: Arel::Node::Offset.

# Solution
---------------------------------------------------------------------------------

I've added a line of code to the Arel::Visitors::HSQLDB#limit_offset method. If the offset is nil or !0, I assume the offset is of type Arel::Node::Offset and call the expr() method, which will return the actual offset.

Signed-off-by: Jason Franklin

# Update
---------------------------------------------------------------------------------
1) I put the fix on a separate branch (not on master, anymore)
2) I've added an offset test to test/db/h2/offset_test.rb