Module: Sequel::Firebird::DatabaseMethods

Extended by:
Database::ResetIdentifierMangling
Included in:
JDBC::Firebird::DatabaseMethods
Defined in:
lib/sequel/adapters/shared/firebird.rb

Constant Summary collapse

AUTO_INCREMENT =
''.freeze
TEMPORARY =
'GLOBAL TEMPORARY '.freeze

Instance Method Summary collapse

Methods included from Database::ResetIdentifierMangling

extended

Instance Method Details

#clear_primary_key(*tables) ⇒ Object



9
10
11
# File 'lib/sequel/adapters/shared/firebird.rb', line 9

def clear_primary_key(*tables)
  tables.each{|t| @primary_keys.delete(dataset.send(:input_identifier, t))}
end

#create_trigger(*args) ⇒ Object



13
14
15
# File 'lib/sequel/adapters/shared/firebird.rb', line 13

def create_trigger(*args)
  self << create_trigger_sql(*args)
end

#database_typeObject



17
18
19
# File 'lib/sequel/adapters/shared/firebird.rb', line 17

def database_type
  :firebird
end

#drop_sequence(name) ⇒ Object



21
22
23
# File 'lib/sequel/adapters/shared/firebird.rb', line 21

def drop_sequence(name)
  self << drop_sequence_sql(name)
end

#primary_key(table) ⇒ Object

Return primary key for the given table.



26
27
28
29
30
31
32
# File 'lib/sequel/adapters/shared/firebird.rb', line 26

def primary_key(table)
  t = dataset.send(:input_identifier, table)
  @primary_keys.fetch(t) do
    pk = fetch("SELECT RDB$FIELD_NAME FROM RDB$INDEX_SEGMENTS NATURAL JOIN RDB$RELATION_CONSTRAINTS WHERE RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' AND RDB$RELATION_NAME = ?", t).single_value
    @primary_keys[t] = dataset.send(:output_identifier, pk.rstrip) if pk
  end
end

#restart_sequence(*args) ⇒ Object



34
35
36
# File 'lib/sequel/adapters/shared/firebird.rb', line 34

def restart_sequence(*args)
  self << restart_sequence_sql(*args)
end

#sequences(opts = OPTS) ⇒ Object



38
39
40
41
# File 'lib/sequel/adapters/shared/firebird.rb', line 38

def sequences(opts=OPTS)
  ds = self[:"rdb$generators"].server(opts[:server]).filter(:"rdb$system_flag" => 0).select(:"rdb$generator_name")
  block_given? ? yield(ds) : ds.map{|r| ds.send(:output_identifier, r[:"rdb$generator_name"])}
end

#tables(opts = OPTS) ⇒ Object



43
44
45
# File 'lib/sequel/adapters/shared/firebird.rb', line 43

def tables(opts=OPTS)
  tables_or_views(0, opts)
end

#views(opts = OPTS) ⇒ Object



47
48
49
# File 'lib/sequel/adapters/shared/firebird.rb', line 47

def views(opts=OPTS)
  tables_or_views(1, opts)
end