jdbc-helper 0.4.5 → 0.4.6

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.
@@ -119,6 +119,14 @@ class Connection
119
119
  # @return [Hash] Accumulated statistics of each type of operation
120
120
  attr_reader :stats
121
121
 
122
+ # JDBC URL of the connection
123
+ # @return [String]
124
+ attr_reader :url
125
+
126
+ # JDBC driver of the connection
127
+ # @return [String]
128
+ attr_reader :driver
129
+
122
130
  # Returns the underlying JDBC Connection object.
123
131
  # Only use this when you really need to access it directly.
124
132
  def jdbc_conn
@@ -135,7 +143,10 @@ class Connection
135
143
  # If a block is given, the connection is automatically closed after executing the block.
136
144
  # @param [Hash] args
137
145
  def initialize(args = {})
138
- # String-tolerance..
146
+ # Subsequent deletes should not affect the input
147
+ args = args.dup
148
+
149
+ # String/Symbol
139
150
  %w[driver url user password timeout].each do | strk |
140
151
  args[strk.to_sym] = args.delete strk if args.has_key? strk
141
152
  end
@@ -143,8 +154,11 @@ class Connection
143
154
  raise ArgumentError.new("driver not given") unless args.has_key? :driver
144
155
  raise ArgumentError.new("url not given") unless args.has_key? :url
145
156
 
157
+ @driver = args.delete :driver
158
+ @url = args.delete :url
159
+
146
160
  begin
147
- Java::JavaClass.for_name args[:driver]
161
+ Java::JavaClass.for_name @driver
148
162
  rescue Exception
149
163
  # TODO
150
164
  raise
@@ -158,7 +172,7 @@ class Connection
158
172
  props.setProperty(key.to_s, args[key]) if args[key]
159
173
  end
160
174
 
161
- @conn = JavaSql::DriverManager.get_connection(args[:url], props)
175
+ @conn = JavaSql::DriverManager.get_connection(@url, props)
162
176
  @spool = StatementPool.send :new, self
163
177
  @bstmt = nil
164
178
 
@@ -119,7 +119,7 @@ class TableWrapper < ObjectWrapper
119
119
  @connection.update(JDBCHelper::SQL.check "drop table #{name}")
120
120
  self
121
121
  end
122
- alias drop_table! truncate!
122
+ alias drop_table! drop!
123
123
 
124
124
  # Select SQL wrapper
125
125
  include Enumerable
@@ -83,6 +83,9 @@ class TestConnection < Test::Unit::TestCase
83
83
 
84
84
  conn = JDBCHelper::Connection.new(conn_info)
85
85
  assert_equal(conn.closed?, false)
86
+ assert_equal(conn.driver, conn_info[:driver] || conn_info['driver'])
87
+ assert_equal(conn.url, conn_info[:url] || conn_info['url'])
88
+
86
89
  conn.close
87
90
  assert_equal(conn.closed?, true)
88
91
  [ :query, :update, :add_batch, :prepare ].each do | met |
@@ -398,7 +398,11 @@ class TestObjectWrapper < Test::Unit::TestCase
398
398
  create_table conn
399
399
  table = conn.table(@table_name)
400
400
  table.drop!
401
+ assert_equal false, drop_table(conn)
401
402
 
403
+ create_table conn
404
+ table = conn.table(@table_name)
405
+ table.drop_table! #alias
402
406
  assert_equal false, drop_table(conn)
403
407
  end
404
408
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jdbc-helper
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.5
5
+ version: 0.4.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Junegunn Choi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-10 00:00:00 +09:00
13
+ date: 2011-06-20 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency