mssql_emulate_lateral_with_apply.rb

lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb
Last Update: 2016-02-11 15:50:14 -0800

The mssql_emulate_lateral_with_apply extension converts queries that use LATERAL into queries that use CROSS/OUTER APPLY, allowing code that works on databases that support LATERAL via Dataset#lateral to run on Microsoft SQL Server and Sybase SQLAnywhere.

This is available as a separate extension instead of integrated into the Microsoft SQL Server and Sybase SQLAnywhere support because few people need it and there is a performance hit to code that doesn't use it.

It is possible there are cases where this emulation does not work. Users should probably verify that correct results are returned when using this extension.

You can load this extension into specific datasets:

ds = DB[:table]
ds = ds.extension(:mssql_emulate_lateral_with_apply)

Or you can load it into all of a database's datasets:

DB.extension(:mssql_emulate_lateral_with_apply)

Related module: Sequel::MSSQL::EmulateLateralWithApply