Module: Sequel::Sequence::Database
- Included in:
- Database
- Defined in:
- lib/sequel/sequence/database.rb,
lib/sequel/sequence/database/sqlite.rb,
lib/sequel/sequence/database/postgresql.rb,
lib/sequel/sequence/database/server/mysql.rb,
lib/sequel/sequence/database/server/mariadb.rb
Defined Under Namespace
Modules: PostgreSQL, SQLite, Server
Constant Summary
collapse
- DANGER_OPT_ID =
"Warning! The new sequence ID can't be less than the current one."
- DANGER_OPT_INCREMENT =
'Warning! Increments greater than 1 are not supported.'
- IF_EXISTS =
'IF EXISTS'
- IF_NOT_EXISTS =
'IF NOT EXISTS'
'created by sequel-sequence'
Instance Method Summary
collapse
Instance Method Details
#build_exists_condition(option) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/sequel/sequence/database.rb', line 69
def build_exists_condition(option)
case option
when true
IF_EXISTS
when false
IF_NOT_EXISTS
end
end
|
#check_options(params) ⇒ Object
12
13
14
15
|
# File 'lib/sequel/sequence/database.rb', line 12
def check_options(params)
log_info DANGER_OPT_INCREMENT if params[:increment] && params[:increment] != 1
log_info DANGER_OPT_INCREMENT if params[:step] && params[:step] != 1
end
|
#check_sequences ⇒ Object
#create_sequence(_name, _options = {}) ⇒ Object
#create_sequence!(name, options = nil) ⇒ Object
89
90
91
92
|
# File 'lib/sequel/sequence/database.rb', line 89
def create_sequence!(name, options = nil)
drop_sequence(name, if_exists: true)
create_sequence(name, options)
end
|
#currval(_name) ⇒ Object
Also known as:
lastval
#custom_sequence?(_sequence_name) ⇒ Boolean
#delete_to_currval(_name) ⇒ Object
#drop_sequence(_name, _options = {}) ⇒ Object
#drop_sequence?(*names) ⇒ Boolean
82
83
84
85
86
87
|
# File 'lib/sequel/sequence/database.rb', line 82
def drop_sequence?(*names)
names.each do |n|
drop_sequence(n, if_exists: true)
end
false
end
|
#nextval_with_label(_name, _num_label = 0) ⇒ Object
#quote(name) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/sequel/sequence/database.rb', line 41
def quote(name)
unless respond_to?(:quote_sequence_name, false)
raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
end
name.to_s.split('.', 2).map { |part| quote_sequence_name(part) }.join('.')
end
|
#quote_name(name) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/sequel/sequence/database.rb', line 33
def quote_name(name)
unless respond_to?(:quote_column_name, false)
raise Sequel::MethodNotAllowed, Sequel::Database::METHOD_NOT_ALLOWED
end
name.to_s.split('.', 2).map { |part| quote_column_name(part) }.join('.')
end
|
#setval(_name, _value) ⇒ Object