| Class | Sequel::Firebird::Dataset |
| In: |
lib/sequel_core/adapters/firebird.rb
|
| Parent: | Sequel::Dataset |
| 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 |
Yield all rows returned by executing the given SQL and converting the types.
# 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 given values into the database.
# 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
Use the RETURNING clause to return the primary key of the inserted record, if it exists
# 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
Use the RETURNING clause to return the columns listed in returning.
# 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 a record returning the record inserted
# 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
# 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