dohruby 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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)
@@ -2,14 +2,11 @@ module DohDb
2
2
 
3
3
  class Handle
4
4
  def insert_hash(hash, table)
5
- names = []
6
- values = []
7
- hash.each_pair do |key, value|
8
- next if value.nil?
9
- names.push(key)
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)
@@ -0,0 +1,9 @@
1
+ module DohDb
2
+
3
+ class Unquoted < String
4
+ def to_sql
5
+ to_s
6
+ end
7
+ end
8
+
9
+ end
@@ -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($doh_unit_test_error_acceptor.events.pop)
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.15
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-21 00:00:00 -06:00
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