Class: Sequel::DataObjects::Dataset

Inherits:
Sequel::Dataset show all
Defined in:
lib/sequel/adapters/do.rb

Overview

Dataset class for Sequel::DataObjects::Database objects.

Direct Known Subclasses

MySQL::Dataset

Constant Summary

Constants inherited from Sequel::Dataset

Sequel::Dataset::ACTION_METHODS, Sequel::Dataset::ALL, Sequel::Dataset::AND_SEPARATOR, Sequel::Dataset::APOS, Sequel::Dataset::APOS_RE, Sequel::Dataset::ARG_BLOCK_ERROR_MSG, Sequel::Dataset::ARRAY_ACCESS_ERROR_MSG, Sequel::Dataset::ARRAY_EMPTY, Sequel::Dataset::AS, Sequel::Dataset::ASC, Sequel::Dataset::BACKSLASH, Sequel::Dataset::BITCOMP_CLOSE, Sequel::Dataset::BITCOMP_OPEN, Sequel::Dataset::BITWISE_METHOD_MAP, Sequel::Dataset::BOOL_FALSE, Sequel::Dataset::BOOL_TRUE, Sequel::Dataset::BRACKET_CLOSE, Sequel::Dataset::BRACKET_OPEN, Sequel::Dataset::CASE_ELSE, Sequel::Dataset::CASE_END, Sequel::Dataset::CASE_OPEN, Sequel::Dataset::CASE_THEN, Sequel::Dataset::CASE_WHEN, Sequel::Dataset::CAST_OPEN, Sequel::Dataset::COLON, Sequel::Dataset::COLUMN_CHANGE_OPTS, Sequel::Dataset::COLUMN_REF_RE1, Sequel::Dataset::COLUMN_REF_RE2, Sequel::Dataset::COLUMN_REF_RE3, Sequel::Dataset::COMMA, Sequel::Dataset::COMMA_SEPARATOR, Sequel::Dataset::CONDITIONED_JOIN_TYPES, Sequel::Dataset::CONDITION_FALSE, Sequel::Dataset::CONDITION_TRUE, Sequel::Dataset::COUNT_FROM_SELF_OPTS, Sequel::Dataset::COUNT_OF_ALL_AS_COUNT, Sequel::Dataset::DATASET_ALIAS_BASE_NAME, Sequel::Dataset::DATETIME_SECFRACTION_ARG, Sequel::Dataset::DEFAULT, Sequel::Dataset::DEFAULT_PREPARED_STATEMENT_MODULE_METHODS, Sequel::Dataset::DEFAULT_VALUES, Sequel::Dataset::DELETE, Sequel::Dataset::DESC, Sequel::Dataset::DISTINCT, Sequel::Dataset::DOT, Sequel::Dataset::DOUBLE_APOS, Sequel::Dataset::DOUBLE_QUOTE, Sequel::Dataset::EMPTY_PARENS, Sequel::Dataset::EMULATED_FUNCTION_MAP, Sequel::Dataset::EQUAL, Sequel::Dataset::ESCAPE, Sequel::Dataset::EXISTS, Sequel::Dataset::EXTENSIONS, Sequel::Dataset::EXTRACT, Sequel::Dataset::FILTER, Sequel::Dataset::FORMAT_DATE, Sequel::Dataset::FORMAT_DATE_STANDARD, Sequel::Dataset::FORMAT_OFFSET, Sequel::Dataset::FORMAT_TIMESTAMP_RE, Sequel::Dataset::FORMAT_USEC, Sequel::Dataset::FOR_UPDATE, Sequel::Dataset::FRAME_ALL, Sequel::Dataset::FRAME_ROWS, Sequel::Dataset::FROM, Sequel::Dataset::FUNCTION_DISTINCT, Sequel::Dataset::GROUP_BY, Sequel::Dataset::HAVING, Sequel::Dataset::IMPORT_ERROR_MSG, Sequel::Dataset::INSERT, Sequel::Dataset::INTO, Sequel::Dataset::IS_LITERALS, Sequel::Dataset::IS_OPERATORS, Sequel::Dataset::JOIN_METHODS, Sequel::Dataset::LATERAL, Sequel::Dataset::LIKE_OPERATORS, Sequel::Dataset::LIMIT, Sequel::Dataset::MUTATION_METHODS, Sequel::Dataset::NON_SQL_OPTIONS, Sequel::Dataset::NOTIMPL_MSG, Sequel::Dataset::NOT_SPACE, Sequel::Dataset::NULL, Sequel::Dataset::NULLS_FIRST, Sequel::Dataset::NULLS_LAST, Sequel::Dataset::N_ARITY_OPERATORS, Sequel::Dataset::OFFSET, Sequel::Dataset::ON, Sequel::Dataset::ON_PAREN, Sequel::Dataset::OPTS, Sequel::Dataset::ORDER_BY, Sequel::Dataset::ORDER_BY_NS, Sequel::Dataset::OVER, Sequel::Dataset::PAREN_CLOSE, Sequel::Dataset::PAREN_OPEN, Sequel::Dataset::PAREN_SPACE_OPEN, Sequel::Dataset::PARTITION_BY, Sequel::Dataset::PREPARED_ARG_PLACEHOLDER, Sequel::Dataset::PREPARED_STATEMENT_MODULE_CODE, Sequel::Dataset::QUALIFY_KEYS, Sequel::Dataset::QUERY_METHODS, Sequel::Dataset::QUESTION_MARK, Sequel::Dataset::QUESTION_MARK_RE, Sequel::Dataset::QUOTE, Sequel::Dataset::QUOTE_RE, Sequel::Dataset::REGEXP_OPERATORS, Sequel::Dataset::RETURNING, Sequel::Dataset::SELECT, Sequel::Dataset::SET, Sequel::Dataset::SPACE, Sequel::Dataset::SPACE_WITH, Sequel::Dataset::SQL_WITH, Sequel::Dataset::STANDARD_TIMESTAMP_FORMAT, Sequel::Dataset::TILDE, Sequel::Dataset::TIMESTAMP_FORMAT, Sequel::Dataset::TWO_ARITY_OPERATORS, Sequel::Dataset::UNCONDITIONED_JOIN_TYPES, Sequel::Dataset::UNDERSCORE, Sequel::Dataset::UNION_ALL_SELECT, Sequel::Dataset::UPDATE, Sequel::Dataset::USING, Sequel::Dataset::VALUES, Sequel::Dataset::WHERE, Sequel::Dataset::WILDCARD, Sequel::Dataset::WITHIN_GROUP, Sequel::Dataset::WITH_ORDINALITY

Instance Attribute Summary

Attributes inherited from Sequel::Dataset

#columns, #db, #opts, #row_proc

Instance Method Summary collapse

Methods inherited from Sequel::Dataset

#<<, #==, #[], #add_graph_aliases, #aliased_expression_sql_append, #all, #and, #array_sql_append, #avg, #bind, #boolean_constant_sql_append, #call, #case_expression_sql_append, #cast_sql_append, clause_methods, #clone, #column_all_sql_append, #columns!, #complex_expression_sql_append, #constant_sql_append, #count, #current_datetime, def_mutation_method, def_sql_method, #delayed_evaluation_sql_append, #delete, #distinct, #dup, #each, #each_server, #empty?, #eql?, #escape_like, #except, #exclude, #exclude_having, #exclude_where, #exists, #extension, #extension!, #filter, #first, #first!, #first_source, #first_source_alias, #first_source_table, #for_update, #freeze, #from, #from_self, #from_self!, #frozen?, #function_sql_append, #get, #graph, #grep, #group, #group_and_count, #group_append, #group_by, #group_cube, #group_rollup, #grouping_sets, #hash, #having, #identifier_input_method, #identifier_input_method=, #identifier_output_method, #identifier_output_method=, #import, #initialize, #insert, #insert_sql, #inspect, #intersect, #interval, #invert, #join, #join_clause_sql_append, #join_on_clause_sql_append, #join_table, #join_using_clause_sql_append, #joined_dataset?, #last, #lateral, #limit, #literal_append, #lock_style, #map, #max, #min, #multi_insert, #multi_insert_sql, #naked, #naked!, #negative_boolean_constant_sql_append, #offset, #or, #order, #order_append, #order_by, #order_more, #order_prepend, #ordered_expression_sql_append, #paged_each, #placeholder_literal_string_sql_append, #prepare, #provides_accurate_rows_matched?, #qualified_identifier_sql_append, #qualify, #quote_identifier_append, #quote_identifiers=, #quote_identifiers?, #quote_schema_table_append, #quoted_identifier_append, #range, #recursive_cte_requires_column_aliases?, register_extension, #requires_placeholder_type_specifiers?, #requires_sql_standard_datetimes?, #returning, #reverse, #reverse_order, #row_number_column, #schema_and_table, #select, #select_all, #select_append, #select_group, #select_hash, #select_hash_groups, #select_map, #select_more, #select_order_map, #server, #server?, #set_graph_aliases, #single_record, #single_record!, #single_value, #single_value!, #skip_locked, #split_alias, #split_qualifiers, #sql, #subscript_sql_append, #sum, #supports_cte?, #supports_cte_in_subqueries?, #supports_derived_column_lists?, #supports_distinct_on?, #supports_group_cube?, #supports_group_rollup?, #supports_grouping_sets?, #supports_insert_select?, #supports_intersect_except?, #supports_intersect_except_all?, #supports_is_true?, #supports_join_using?, #supports_lateral_subqueries?, #supports_limits_in_correlated_subqueries?, #supports_modifying_joins?, #supports_multiple_column_in?, #supports_offsets_in_correlated_subqueries?, #supports_ordered_distinct_on?, #supports_regexp?, #supports_replace?, #supports_returning?, #supports_select_all_and_column?, #supports_skip_locked?, #supports_timestamp_timezones?, #supports_timestamp_usecs?, #supports_where_true?, #supports_window_functions?, #to_hash, #to_hash_groups, #truncate, #truncate_sql, #unbind, #unfiltered, #ungraphed, #ungrouped, #union, #unlimited, #unordered, #unqualified_column_for, #unused_table_alias, #update, #update_sql, #where, #window_sql_append, #with, #with_recursive, #with_sql, #with_sql_all, #with_sql_delete, #with_sql_each, #with_sql_first, #with_sql_insert, #with_sql_single_value

Methods included from Metaprogramming

#meta_def

Methods included from SQL::StringMethods

#ilike, #like

Methods included from SQL::OrderMethods

#asc, #desc

Methods included from SQL::NumericMethods

#+, #coerce

Methods included from SQL::ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from SQL::CastMethods

#cast, #cast_numeric, #cast_string

Methods included from SQL::BooleanMethods

#~

Methods included from SQL::AliasMethods

#as

Constructor Details

This class inherits a constructor from Sequel::Dataset

Instance Method Details

#fetch_rows(sql) ⇒ Object

Execute the SQL on the database and yield the rows as hashes with symbol keys.



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/sequel/adapters/do.rb', line 145

def fetch_rows(sql)
  execute(sql) do |reader|
    cols = self.columns = reader.fields.map{|f| output_identifier(f)}
    while(reader.next!) do
      h = {}
      cols.zip(reader.values).each{|k, v| h[k] = v}
      yield h
    end
  end
  self
end