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



11
12
13
# File 'lib/sequel/adapters/shared/firebird.rb', line 11

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

#create_trigger(*args) ⇒ Object



15
16
17
# File 'lib/sequel/adapters/shared/firebird.rb', line 15

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

#database_typeObject



19
20
21
# File 'lib/sequel/adapters/shared/firebird.rb', line 19

def database_type
  :firebird
end

#drop_sequence(name) ⇒ Object



23
24
25
# File 'lib/sequel/adapters/shared/firebird.rb', line 23

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

#primary_key(table) ⇒ Object

Return primary key for the given table.



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

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



36
37
38
# File 'lib/sequel/adapters/shared/firebird.rb', line 36

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

#sequences(opts = OPTS) ⇒ Object



40
41
42
43
# File 'lib/sequel/adapters/shared/firebird.rb', line 40

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



45
46
47
# File 'lib/sequel/adapters/shared/firebird.rb', line 45

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

#views(opts = OPTS) ⇒ Object



49
50
51
# File 'lib/sequel/adapters/shared/firebird.rb', line 49

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