Class: Sequel::Firebird::Dataset

Class | Sequel::Firebird::Dataset
In: | lib/sequel_core/adapters/firebird.rb
Parent: | Sequel::Dataset

Dataset class for Firebird datasets

### Methods

fetch_rows insert insert_returning_pk_sql insert_returning_sql insert_select literal select_clause_order select_limit_sql

### Included Modules

UnsupportedIntersectExcept

### Constants

BOOL_TRUE | = | '1'.freeze
BOOL_FALSE | = | '0'.freeze
COMMA_SEPARATOR | = | ', '.freeze
FIREBIRD_TIMESTAMP_FORMAT | = | "TIMESTAMP '%Y-%m-%d %H:%M:%S".freeze
SELECT_CLAUSE_ORDER | = | %w'distinct limit columns from join where group having compounds order'.freeze

### Public Instance methods

fetch_rows(sql) {|h| ...}

Yield all rows returned by executing the given SQL and converting the types.

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 225
    225:       def fetch_rows(sql, &block)
    226:         execute(sql) do |s|
    227:           begin
    228:             @columns = s.fields.map{|c| output_identifier(c.name)}
    229:             s.fetchall(:symbols_hash).each do |r|
    230:               h = {}
    231:               r.each{|k,v| h[output_identifier(k)] = v}
    232:               yield h
    233:             end
    234:           ensure
    235:             s.close
    236:           end
    237:         end
    238:         self
    239:       end

insert(*values)

Insert given values into the database.

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 242
    242:       def insert(*values)
    243:         if !@opts[:sql]
    244:           single_value(:sql=>insert_returning_pk_sql(*values))
    245:         else
    246:           execute_insert(insert_sql(*values), :table=>opts[:from].first,
    247:             :values=>values.size == 1 ? values.first : values)
    248:         end
    249:       end

insert_returning_pk_sql(*values)

Use the RETURNING clause to return the primary key of the inserted record, if it exists

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 252
    252:       def insert_returning_pk_sql(*values)
    253:         pk = db.primary_key(opts[:from].first)
    254:         insert_returning_sql(pk ? Sequel::SQL::Identifier.new(pk) : 'NULL'.lit, *values)
    255:       end

insert_returning_sql(returning, *values)

Use the RETURNING clause to return the columns listed in returning.

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 258
    258:       def insert_returning_sql(returning, *values)
    259:         "#{insert_sql(*values)} RETURNING #{column_list(Array(returning))}"
    260:       end

insert_select(*values)

Insert a record returning the record inserted

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 263
    263:       def insert_select(*values)
    264:         single_record(:naked=>true, :sql=>insert_returning_sql(nil, *values))
    265:       end

literal(v)

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 267
    267:       def literal(v)
    268:         case v
    269:         when Time, DateTime
    270:           "#{v.strftime(FIREBIRD_TIMESTAMP_FORMAT)}.#{sprintf("%04d",v.usec / 100)}'"
    271:         when TrueClass
    272:           BOOL_TRUE
    273:         when FalseClass
    274:           BOOL_FALSE
    275:         else
    276:           super
    277:         end
    278:       end

select_clause_order()

The order of clauses in the SELECT SQL statement

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 281
    281:       def select_clause_order
    282:         SELECT_CLAUSE_ORDER
    283:       end

select_limit_sql(sql, opts)

[Source]

         # File lib/sequel_core/adapters/firebird.rb, line 285
    285:       def select_limit_sql(sql, opts)
    286:         sql << " FIRST #{opts[:limit]}" if opts[:limit]
    287:         sql << " SKIP #{opts[:offset]}" if opts[:offset]
    288:       end

[Validate]