Files

Class Index [+]

Quicksearch

Ubiquo::Adapters::Sqlite::InstanceMethods

Public Instance Methods

create_regexp_method() click to toggle source

creates a regexp method to allow use the REGEXP operator

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 28
28:         def create_regexp_method
29:           @connection.create_function('regexp', 2) do |func, pattern, expression|
30:             regexp = Regexp.new(pattern.to_s, Regexp::IGNORECASE)
31:             func.result = expression.to_s.match(regexp) ? 1 : 0
32:           end
33:         end
create_sequence(name) click to toggle source

Creates a sequence with name “name”. Drops it before if it exists

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 36
36:         def create_sequence(name)
37:           drop_sequence(name)
38:           self.execute("CREATE TABLE %s_sequence (id INTEGER PRIMARY KEY AUTOINCREMENT)" % name)
39:         end
drop_sequence(name) click to toggle source

Drops a sequence with name “name” if exists

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 42
42:         def drop_sequence(name)
43:           self.execute("DROP TABLE IF EXISTS %s_sequence" % name)
44:         end
initialize_with_regexp(connection, logger, config) click to toggle source

(Not documented)

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 22
22:         def initialize_with_regexp connection, logger, config
23:           initialize_without_regexp connection, logger, config
24:           create_regexp_method
25:         end
list_sequences(starts_with) click to toggle source

Returns an array containing a list of the existing sequences that start with the given string

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 47
47:         def list_sequences(starts_with)
48:           self.execute("SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' AND name LIKE '#{starts_with}%'").map { |result| result['name'].gsub('_sequence', '') }
49:         end
next_val_sequence(name) click to toggle source

Returns the next value for the sequence “name“

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 52
52:         def next_val_sequence(name)
53:           val = self.insert_sql("INSERT INTO %s_sequence VALUES(NULL)" % name)
54:           # In jdbcsqlite, insert_sql is not implemented
55:           val ||= last_insert_id("#{name}_sequence", nil) rescue nil
56:         end
reset_sequence_value(name, next_value = nil) click to toggle source

Reset a sequence so that it will return the specified value as the next one If next_value is not specified, the sequence will be reset to the “most appropiate value”, considering the values of existing records using this sequence

    # File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 61
61:         def reset_sequence_value(name, next_value = nil)
62:           create_sequence(name)
63:           unless next_value
64:             table, field = name.split('_$_')
65:             next_value = self.execute('SELECT MAX(%s) as max FROM %s' % [field, table]).first['max'].to_i + 1
66:           end
67:           self.execute("INSERT INTO %s_sequence VALUES(%s)" % [name, (next_value || 1) - 1])
68:         end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.