class Baza::Driver::Tiny
Constants
- SEPARATOR_COLUMN
- SEPARATOR_DATABASE
- SEPARATOR_INDEX
- SEPARATOR_TABLE
- SEPARATOR_VALUE
Public Class Methods
escape_column(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 38 def self.escape_column(name) escape_identifier(name) end
escape_database(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 34 def self.escape_database(name) escape_identifier(name) end
escape_identifier(string)
click to toggle source
# File lib/baza/driver/tiny.rb, line 28 def self.escape_identifier(string) string = string.to_s raise "Invalid column-string: #{string}" if string.include?("[") || string.include?("]") string end
escape_index(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 42 def self.escape_index(name) escape_identifier(name) end
escape_table(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 46 def self.escape_table(name) escape_identifier(name) end
new(db)
click to toggle source
Calls superclass method
Baza::BaseSqlDriver::new
# File lib/baza/driver/tiny.rb, line 8 def initialize(db) @sep_database = SEPARATOR_DATABASE @sep_table = SEPARATOR_TABLE @sep_col = SEPARATOR_COLUMN @sep_val = SEPARATOR_VALUE @sep_index = SEPARATOR_INDEX super @client = TinyTds::Client.new(username: db.opts.fetch(:user), password: db.opts.fetch(:pass), host: db.opts.fetch(:host)) end
quote_column(column_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 89 def self.quote_column(column_name) quote_identifier(column_name) end
quote_database(database_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 85 def self.quote_database(database_name) quote_identifier(database_name) end
quote_identifier(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 81 def self.quote_identifier(name) "[#{escape_database(name)}]" end
quote_index(index_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 93 def self.quote_index(index_name) quote_identifier(index_name) end
quote_table(table_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 97 def self.quote_table(table_name) quote_identifier(table_name) end
Public Instance Methods
close()
click to toggle source
# File lib/baza/driver/tiny.rb, line 20 def close @client.close end
escape(value)
click to toggle source
# File lib/baza/driver/tiny.rb, line 24 def escape(value) @client.escape(value) end
escape_column(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 54 def escape_column(name) self.class.escape_identifier(name) end
escape_database(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 50 def escape_database(name) self.class.escape_identifier(name) end
escape_index(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 58 def escape_index(name) self.class.escape_identifier(name) end
escape_table(name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 62 def escape_table(name) self.class.escape_identifier(name) end
insert(table_name, data, args = {})
click to toggle source
# File lib/baza/driver/tiny.rb, line 66 def insert(table_name, data, args = {}) sql = Baza::SqlQueries::GenericInsert.new({ db: @db, table_name: table_name, data: data }.merge(args)).to_sql result = @client.execute(sql) result.insert if args[:return_id] end
query(sql)
click to toggle source
# File lib/baza/driver/tiny.rb, line 77 def query(sql) Baza::Driver::Tiny::Result.new(@client.execute(sql)) end
quote_column(column_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 105 def quote_column(column_name) self.class.quote_identifier(column_name) end
quote_database(database_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 101 def quote_database(database_name) self.class.quote_identifier(database_name) end
quote_index(index_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 109 def quote_index(index_name) self.class.quote_identifier(index_name) end
quote_table(table_name)
click to toggle source
# File lib/baza/driver/tiny.rb, line 113 def quote_table(table_name) self.class.quote_identifier(table_name) end