Class: Sequel::ADO::MSSQL::Dataset

Inherits:
ADO::Dataset
  • Object
show all
Includes:
MSSQL::DatasetMethods
Defined in:
lib/sequel/adapters/ado/mssql.rb

Constant Summary

Constants included from MSSQL::DatasetMethods

MSSQL::DatasetMethods::CONSTANT_MAP, MSSQL::DatasetMethods::EXTRACT_MAP, MSSQL::DatasetMethods::LIMIT_ALL

Instance Method Summary collapse

Methods included from MSSQL::DatasetMethods

#complex_expression_sql_append, #constant_sql_append, #count, #cross_apply, #disable_insert_output, #empty?, #escape_like, #full_text_search, #insert_select, #insert_select_sql, #into, #mssql_unicode_strings, #nolock, #outer_apply, #output, #quoted_identifier_append, #returning, #select_sql, #server_version, #supports_cte?, #supports_group_cube?, #supports_group_rollup?, #supports_grouping_sets?, #supports_insert_select?, #supports_intersect_except?, #supports_is_true?, #supports_join_using?, #supports_merge?, #supports_modifying_joins?, #supports_multiple_column_in?, #supports_nowait?, #supports_offsets_in_correlated_subqueries?, #supports_output_clause?, #supports_returning?, #supports_skip_locked?, #supports_where_true?, #supports_window_functions?, #with_mssql_unicode_strings, #with_ties

Methods included from EmulateOffsetWithRowNumber

#empty?, #select_sql, #supports_offsets_in_correlated_subqueries?

Instance Method Details

#insert(*values) ⇒ Object

Use a nasty hack of multiple SQL statements in the same call and having the last one return the most recently inserted id. This is necessary as ADO's default :provider uses a separate native connection for each query.



49
50
51
52
# File 'lib/sequel/adapters/ado/mssql.rb', line 49

def insert(*values)
  return super if (@opts[:sql] && !@opts[:prepared_sql]) || @opts[:returning]
  with_sql("SET NOCOUNT ON; #{insert_sql(*values)}; SELECT CAST(SCOPE_IDENTITY() AS INTEGER)").single_value
end

#provides_accurate_rows_matched?Boolean

If you use a better :provider option for the database, you can get an accurate number of rows matched.

Returns:

  • (Boolean)


56
57
58
# File 'lib/sequel/adapters/ado/mssql.rb', line 56

def provides_accurate_rows_matched?
  !!db.opts[:provider]
end