dohruby 0.1.15 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/doh/mysql/hash_util.rb +17 -8
- data/lib/doh/mysql/unquoted.rb +9 -0
- data/lib/doh/util/unit_test_logging.rb +8 -0
- data/test/mysql/tc_connector_instance.rb +1 -1
- data/test/mysql/tc_unquoted.rb +16 -0
- metadata +5 -2
data/CHANGELOG
CHANGED
@@ -56,3 +56,8 @@
|
|
56
56
|
* added create_tables function to DatabaseCreator
|
57
57
|
* added notify to logger interface
|
58
58
|
* add DohDb::ReadOnlyRow::each_pair
|
59
|
+
*0.1.16* (May 22nd, 2008)
|
60
|
+
* add Doh::pop_unit_test_error function
|
61
|
+
* add DohDb::Unquoted class
|
62
|
+
*0.1.17* (May 23rd, 2008)
|
63
|
+
* added Handle::replace_hash (in hash_util)
|
data/lib/doh/mysql/hash_util.rb
CHANGED
@@ -2,14 +2,11 @@ module DohDb
|
|
2
2
|
|
3
3
|
class Handle
|
4
4
|
def insert_hash(hash, table)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
values.push(value.to_sql)
|
11
|
-
end
|
12
|
-
insert("INSERT INTO #{table} (#{names.join(',')}) VALUES (#{values.join(',')})")
|
5
|
+
insert_hash_helper(hash, table, 'INSERT')
|
6
|
+
end
|
7
|
+
|
8
|
+
def replace_hash(hash, table)
|
9
|
+
insert_hash_helper(hash, table, 'REPLACE')
|
13
10
|
end
|
14
11
|
|
15
12
|
def update_hash(hash, table, primary_key_value, primary_key_name)
|
@@ -23,6 +20,18 @@ class Handle
|
|
23
20
|
hash
|
24
21
|
end
|
25
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def insert_hash_helper(hash, table, keyword)
|
26
|
+
names = []
|
27
|
+
values = []
|
28
|
+
hash.each_pair do |key, value|
|
29
|
+
next if value.nil?
|
30
|
+
names.push(key)
|
31
|
+
values.push(value.to_sql)
|
32
|
+
end
|
33
|
+
insert("#{keyword} INTO #{table} (#{names.join(',')}) VALUES (#{values.join(',')})")
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
def self.insert_hash(hash, table)
|
@@ -21,3 +21,11 @@ intrfc = DohLogger::StandardInterface.new(scheduler)
|
|
21
21
|
intrfc.add_acceptor(DohLogger::DEBUG, file_acceptor)
|
22
22
|
intrfc.add_acceptor(DohLogger::ERROR, $doh_unit_test_error_acceptor)
|
23
23
|
Doh::set_logger_interface(intrfc)
|
24
|
+
|
25
|
+
module Doh
|
26
|
+
|
27
|
+
def self.pop_unit_test_error
|
28
|
+
$doh_unit_test_error_acceptor.events.pop
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -17,7 +17,7 @@ class TC_ConnectorInstance < Test::Unit::TestCase
|
|
17
17
|
assert_raise(QueryResultError) {DohDb::select_field("SELECT money FROM #{tbl} WHERE id = 7")}
|
18
18
|
assert_equal(1, DohDb::update_row("UPDATE #{tbl} SET money = 10.95 WHERE id = 1"))
|
19
19
|
assert_raise(Mysql::Error){DohDb::query("some invalid sql here")}
|
20
|
-
assert(
|
20
|
+
assert(Doh::pop_unit_test_error)
|
21
21
|
assert_raise(QueryResultError) {DohDb::update_row("UPDATE #{tbl} SET money = 10.95 WHERE id = 7")}
|
22
22
|
onerow = DohDb::select_row("SELECT * FROM #{tbl} WHERE id = 1")
|
23
23
|
assert_equal('1', onerow['id'])
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'doh/mysql/unquoted'
|
3
|
+
|
4
|
+
module DohDb
|
5
|
+
|
6
|
+
class TC_Unquoted < Test::Unit::TestCase
|
7
|
+
def test_stuff
|
8
|
+
assert_equal('', Unquoted.new)
|
9
|
+
assert_equal('blah', Unquoted.new('blah'))
|
10
|
+
assert_equal('blah', Unquoted.new('blah').to_s)
|
11
|
+
assert_equal('blah', Unquoted.new('blah').to_sql)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dohruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makani & Kem Mason
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-23 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/doh/mysql/readonly_row.rb
|
80
80
|
- lib/doh/mysql/to_sql.rb
|
81
81
|
- lib/doh/mysql/typed_row_builder.rb
|
82
|
+
- lib/doh/mysql/unquoted.rb
|
82
83
|
- lib/doh/mysql.rb
|
83
84
|
- lib/doh/unit_test.rb
|
84
85
|
- lib/doh/util
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- test/mysql/tc_hash_util.rb
|
110
111
|
- test/mysql/tc_parse.rb
|
111
112
|
- test/mysql/tc_readonly_row.rb
|
113
|
+
- test/mysql/tc_unquoted.rb
|
112
114
|
- README
|
113
115
|
- MIT-LICENSE
|
114
116
|
- CHANGELOG
|
@@ -153,3 +155,4 @@ test_files:
|
|
153
155
|
- test/mysql/tc_hash_util.rb
|
154
156
|
- test/mysql/tc_parse.rb
|
155
157
|
- test/mysql/tc_readonly_row.rb
|
158
|
+
- test/mysql/tc_unquoted.rb
|