Class: Baza::Driver::Tiny
Defined Under Namespace
Classes: Commands, Result
Constant Summary
collapse
- SEPARATOR_DATABASE =
"]".freeze
- SEPARATOR_TABLE =
"]".freeze
- SEPARATOR_COLUMN =
"]".freeze
- SEPARATOR_INDEX =
"]".freeze
- SEPARATOR_VALUE =
"'".freeze
BaseSqlDriver::SELECT_ARGS_ALLOWED_KEYS
Instance Attribute Summary
#cols, #conn, #db, #indexes, #sep_col, #sep_database, #sep_index, #sep_table, #sep_val, #tables
Class Method Summary
collapse
Instance Method Summary
collapse
#count, #delete, escape, #foreign_key_support?, from_object, #insert_multi, #quote_value, quote_value, #select, #single, #sql_make_where, #supports_multiple_databases?, #transaction
Constructor Details
#initialize(db) ⇒ Tiny
Returns a new instance of Tiny.
Class Method Details
.escape_column(name) ⇒ Object
38
39
40
|
# File 'lib/baza/driver/tiny.rb', line 38
def self.escape_column(name)
escape_identifier(name)
end
|
.escape_database(name) ⇒ Object
34
35
36
|
# File 'lib/baza/driver/tiny.rb', line 34
def self.escape_database(name)
escape_identifier(name)
end
|
.escape_identifier(string) ⇒ Object
28
29
30
31
32
|
# 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) ⇒ Object
42
43
44
|
# File 'lib/baza/driver/tiny.rb', line 42
def self.escape_index(name)
escape_identifier(name)
end
|
.escape_table(name) ⇒ Object
46
47
48
|
# File 'lib/baza/driver/tiny.rb', line 46
def self.escape_table(name)
escape_identifier(name)
end
|
.quote_column(column_name) ⇒ Object
89
90
91
|
# File 'lib/baza/driver/tiny.rb', line 89
def self.quote_column(column_name)
quote_identifier(column_name)
end
|
.quote_database(database_name) ⇒ Object
85
86
87
|
# File 'lib/baza/driver/tiny.rb', line 85
def self.quote_database(database_name)
quote_identifier(database_name)
end
|
.quote_identifier(name) ⇒ Object
81
82
83
|
# File 'lib/baza/driver/tiny.rb', line 81
def self.quote_identifier(name)
"[#{escape_database(name)}]"
end
|
.quote_index(index_name) ⇒ Object
93
94
95
|
# File 'lib/baza/driver/tiny.rb', line 93
def self.quote_index(index_name)
quote_identifier(index_name)
end
|
.quote_table(table_name) ⇒ Object
97
98
99
|
# File 'lib/baza/driver/tiny.rb', line 97
def self.quote_table(table_name)
quote_identifier(table_name)
end
|
Instance Method Details
#close ⇒ Object
20
21
22
|
# File 'lib/baza/driver/tiny.rb', line 20
def close
@client.close
end
|
#escape(value) ⇒ Object
24
25
26
|
# File 'lib/baza/driver/tiny.rb', line 24
def escape(value)
@client.escape(value)
end
|
#escape_column(name) ⇒ Object
54
55
56
|
# File 'lib/baza/driver/tiny.rb', line 54
def escape_column(name)
self.class.escape_identifier(name)
end
|
#escape_database(name) ⇒ Object
50
51
52
|
# File 'lib/baza/driver/tiny.rb', line 50
def escape_database(name)
self.class.escape_identifier(name)
end
|
#escape_index(name) ⇒ Object
58
59
60
|
# File 'lib/baza/driver/tiny.rb', line 58
def escape_index(name)
self.class.escape_identifier(name)
end
|
#escape_table(name) ⇒ Object
62
63
64
|
# File 'lib/baza/driver/tiny.rb', line 62
def escape_table(name)
self.class.escape_identifier(name)
end
|
#insert(table_name, data, args = {}) ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# 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) ⇒ Object
77
78
79
|
# File 'lib/baza/driver/tiny.rb', line 77
def query(sql)
Baza::Driver::Tiny::Result.new(@client.execute(sql))
end
|
#quote_column(column_name) ⇒ Object
105
106
107
|
# File 'lib/baza/driver/tiny.rb', line 105
def quote_column(column_name)
self.class.quote_identifier(column_name)
end
|
#quote_database(database_name) ⇒ Object
101
102
103
|
# File 'lib/baza/driver/tiny.rb', line 101
def quote_database(database_name)
self.class.quote_identifier(database_name)
end
|
#quote_index(index_name) ⇒ Object
109
110
111
|
# File 'lib/baza/driver/tiny.rb', line 109
def quote_index(index_name)
self.class.quote_identifier(index_name)
end
|
#quote_table(table_name) ⇒ Object
113
114
115
|
# File 'lib/baza/driver/tiny.rb', line 113
def quote_table(table_name)
self.class.quote_identifier(table_name)
end
|