| Class | Sequel::Firebird::Dataset |
| In: |
lib/sequel/adapters/firebird.rb
|
| Parent: | Sequel::Dataset |
| BOOL_TRUE | = | '1'.freeze |
| BOOL_FALSE | = | '0'.freeze |
| NULL | = | LiteralString.new('NULL').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 |
Yield all rows returned by executing the given SQL and converting the types.
# File lib/sequel/adapters/firebird.rb, line 229
229: def fetch_rows(sql, &block)
230: execute(sql) do |s|
231: begin
232: @columns = s.fields.map{|c| output_identifier(c.name)}
233: s.fetchall(:symbols_hash).each do |r|
234: h = {}
235: r.each{|k,v| h[output_identifier(k)] = v}
236: yield h
237: end
238: ensure
239: s.close
240: end
241: end
242: self
243: end
Insert given values into the database.
# File lib/sequel/adapters/firebird.rb, line 246
246: def insert(*values)
247: if !@opts[:sql]
248: clone(default_server_opts(:sql=>insert_returning_pk_sql(*values))).single_value
249: else
250: execute_insert(insert_sql(*values), :table=>opts[:from].first,
251: :values=>values.size == 1 ? values.first : values)
252: end
253: end
Use the RETURNING clause to return the primary key of the inserted record, if it exists
# File lib/sequel/adapters/firebird.rb, line 256
256: def insert_returning_pk_sql(*values)
257: pk = db.primary_key(opts[:from].first)
258: insert_returning_sql(pk ? Sequel::SQL::Identifier.new(pk) : NULL, *values)
259: end
Use the RETURNING clause to return the columns listed in returning.
# File lib/sequel/adapters/firebird.rb, line 262
262: def insert_returning_sql(returning, *values)
263: "#{insert_sql(*values)} RETURNING #{column_list(Array(returning))}"
264: end
Insert a record returning the record inserted
# File lib/sequel/adapters/firebird.rb, line 267
267: def insert_select(*values)
268: naked.clone(default_server_opts(:sql=>insert_returning_sql(nil, *values))).single_record
269: end