jdbc-helper 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,6 @@
1
+ ### 0.7.5 / 2012/07/28
2
+ * `require 'jdbc-helper/sql'` is allowed in non-Java environments
3
+
1
4
  ### 0.7.4 / 2012/07/09
2
5
  * Revised Connectors
3
6
  * Use `JDBCHelper::MySQL` instead of `JDBCHelper::MySQLConnector`
data/README.markdown CHANGED
@@ -249,11 +249,14 @@ table.drop!
249
249
 
250
250
  #### Building complex where clauses
251
251
  ```ruby
252
- SQL = JDBCHelper::SQL # Shortcut. Or you can just include JDBCHelper
252
+ # Shortcut. Or you can just include JDBCHelper
253
+ SQL = JDBCHelper::SQL
253
254
 
254
- # With Hash
255
+ # With any number of Strings, Arrays and Hashes
255
256
  scope = table.where(
256
- :a => 'abc', # a = 'abc'
257
+ "x <> 'hello'", # x <> 'hello'
258
+ ["y = ? or z > ?", 'abc', 10], # and (y = 'abc' or z > 10)
259
+ :a => 'abc', # and a = 'abc'
257
260
  :b => (1..10), # and b >= 1 and b <= 10
258
261
  :c => (1...10), # and c >= 1 and c < 10
259
262
  :d => %w[a b c], # and d in ('a', 'b', 'c')
@@ -266,9 +269,6 @@ scope = table.where(
266
269
  :k => SQL.le( SQL.expr('sysdate') ) # and k <= sysdate
267
270
  )
268
271
  scope.update(:a => 'xyz')
269
-
270
- # With Array
271
- scope = table.where(["a = ? or b > ?", 'abc', 10])
272
272
  ```
273
273
 
274
274
  #### Invalid use of dynamic conditions
data/jdbc-helper.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = JDBCHelper::VERSION
17
17
 
18
- gem.add_runtime_dependency 'insensitive_hash', '~> 0.2.4'
18
+ gem.add_runtime_dependency 'insensitive_hash', '>= 0.2.4', '< 0.4.0'
19
19
  gem.add_development_dependency "bundler", "~> 1.1.4"
20
20
  gem.add_development_dependency "rcov", "~> 0.9"
21
21
  gem.add_development_dependency "test-unit", ">= 2.3.0"
@@ -4,7 +4,7 @@
4
4
  module JDBCHelper
5
5
  # SQL generator class methods for prepared operations.
6
6
  # WARNING: Does not perform SQL.check to minimize performance overhead
7
- class SQL
7
+ module SQL
8
8
  # Generate SQL snippet, prevents the string from being quoted.
9
9
  # @param [String] SQL snippet
10
10
  # @return [JDBCHelper::SQL::Expression]
@@ -1,6 +1,8 @@
1
1
  # encoding: UTF-8
2
2
  # Junegunn Choi (junegunn.c@gmail.com)
3
3
 
4
+ require 'bigdecimal'
5
+
4
6
  module JDBCHelper
5
7
 
6
8
  # Generate SQL snippet, prevents the string from being quoted.
@@ -16,7 +18,7 @@ class << self
16
18
  end
17
19
 
18
20
  # Class representing an SQL snippet. Also has many SQL generator class methods.
19
- class SQL
21
+ module SQL
20
22
  # Formats the given data so that it can be injected into SQL
21
23
  def self.value data
22
24
  case data
@@ -4,7 +4,7 @@
4
4
  module JDBCHelper
5
5
  # SQL generator class methods for prepared operations.
6
6
  # WARNING: Does not perform SQL.check to minimize performance overhead
7
- class SQLPrepared < JDBCHelper::SQL
7
+ module SQLPrepared
8
8
  # Generates SQL where cluase with the given conditions.
9
9
  # Parameter can be either Hash of String.
10
10
  def self.where *conds
@@ -54,7 +54,7 @@ class SQLPrepared < JDBCHelper::SQL
54
54
  sql = [
55
55
  "select #{opts.fetch(:select, ['*']).join(', ')} from #{table}",
56
56
  w_c.to_s,
57
- order(opts.fetch(:order, []).join(', '))
57
+ SQL.order(opts.fetch(:order, []).join(', '))
58
58
  ].reject(&:empty?).join(' ')
59
59
 
60
60
  return sql, w_b
@@ -0,0 +1,3 @@
1
+ require 'jdbc-helper/sql/sql'
2
+ require 'jdbc-helper/sql/sql_prepared'
3
+ require 'jdbc-helper/sql/expression'
@@ -1,3 +1,3 @@
1
1
  module JDBCHelper
2
- VERSION = '0.7.4'
2
+ VERSION = '0.7.5'
3
3
  end
data/lib/jdbc-helper.rb CHANGED
@@ -8,9 +8,7 @@ if RUBY_PLATFORM.match(/java/).nil?
8
8
  end
9
9
 
10
10
  require 'java'
11
- require 'jdbc-helper/sql/sql'
12
- require 'jdbc-helper/sql/sql_prepared'
13
- require 'jdbc-helper/sql/expression'
11
+ require 'jdbc-helper/sql'
14
12
  require 'jdbc-helper/constants'
15
13
  require 'jdbc-helper/connection'
16
14
  require 'jdbc-helper/connector'
metadata CHANGED
@@ -1,145 +1,166 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jdbc-helper
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.7.4
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.7.5
6
6
  platform: ruby
7
- authors:
8
- - Junegunn Choi
9
- autorequire:
7
+ authors:
8
+ - Junegunn Choi
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-07-09 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: insensitive_hash
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 0.2.4
24
- type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: bundler
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: 1.1.4
35
- type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rcov
39
- prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: "0.9"
46
- type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: test-unit
50
- prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 2.3.0
57
- type: :development
58
- version_requirements: *id004
12
+ date: 2012-07-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: insensitive_hash
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 0.2.4
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.0
24
+ none: false
25
+ requirement: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.4
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.0
33
+ none: false
34
+ prerelease: false
35
+ type: :runtime
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: 1.1.4
43
+ none: false
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 1.1.4
49
+ none: false
50
+ prerelease: false
51
+ type: :development
52
+ - !ruby/object:Gem::Dependency
53
+ name: rcov
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: '0.9'
59
+ none: false
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: '0.9'
65
+ none: false
66
+ prerelease: false
67
+ type: :development
68
+ - !ruby/object:Gem::Dependency
69
+ name: test-unit
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 2.3.0
75
+ none: false
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: 2.3.0
81
+ none: false
82
+ prerelease: false
83
+ type: :development
59
84
  description: A JDBC helper for JRuby/Database developers.
60
- email:
61
- - junegunn.c@gmail.com
85
+ email:
86
+ - junegunn.c@gmail.com
62
87
  executables: []
63
-
64
88
  extensions: []
65
-
66
89
  extra_rdoc_files: []
67
-
68
- files:
69
- - .gitignore
70
- - CHANGELOG.markdown
71
- - Gemfile
72
- - LICENSE.txt
73
- - README.markdown
74
- - Rakefile
75
- - VERSION
76
- - jdbc-helper.gemspec
77
- - lib/jdbc-helper.rb
78
- - lib/jdbc-helper/connection.rb
79
- - lib/jdbc-helper/connection/callable_statement.rb
80
- - lib/jdbc-helper/connection/parameterized_statement.rb
81
- - lib/jdbc-helper/connection/prepared_statement.rb
82
- - lib/jdbc-helper/connection/result_set_enumerator.rb
83
- - lib/jdbc-helper/connection/row.rb
84
- - lib/jdbc-helper/connection/statement_pool.rb
85
- - lib/jdbc-helper/connection/type_map.rb
86
- - lib/jdbc-helper/connector.rb
87
- - lib/jdbc-helper/connector/cassandra.rb
88
- - lib/jdbc-helper/connector/mssql.rb
89
- - lib/jdbc-helper/connector/mysql.rb
90
- - lib/jdbc-helper/connector/oracle.rb
91
- - lib/jdbc-helper/connector/postgresql.rb
92
- - lib/jdbc-helper/constants.rb
93
- - lib/jdbc-helper/sql/expression.rb
94
- - lib/jdbc-helper/sql/sql.rb
95
- - lib/jdbc-helper/sql/sql_prepared.rb
96
- - lib/jdbc-helper/version.rb
97
- - lib/jdbc-helper/wrapper/function_wrapper.rb
98
- - lib/jdbc-helper/wrapper/object_wrapper.rb
99
- - lib/jdbc-helper/wrapper/procedure_wrapper.rb
100
- - lib/jdbc-helper/wrapper/sequence_wrapper.rb
101
- - lib/jdbc-helper/wrapper/table_wrapper.rb
102
- - test/database.yml
103
- - test/helper.rb
104
- - test/performance.rb
105
- - test/test_connection.rb
106
- - test/test_connectors.rb
107
- - test/test_object_wrapper.rb
108
- - test/test_sql.rb
109
- - test/testrb
90
+ files:
91
+ - .gitignore
92
+ - CHANGELOG.markdown
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.markdown
96
+ - Rakefile
97
+ - VERSION
98
+ - jdbc-helper.gemspec
99
+ - lib/jdbc-helper.rb
100
+ - lib/jdbc-helper/connection.rb
101
+ - lib/jdbc-helper/connection/callable_statement.rb
102
+ - lib/jdbc-helper/connection/parameterized_statement.rb
103
+ - lib/jdbc-helper/connection/prepared_statement.rb
104
+ - lib/jdbc-helper/connection/result_set_enumerator.rb
105
+ - lib/jdbc-helper/connection/row.rb
106
+ - lib/jdbc-helper/connection/statement_pool.rb
107
+ - lib/jdbc-helper/connection/type_map.rb
108
+ - lib/jdbc-helper/connector.rb
109
+ - lib/jdbc-helper/connector/cassandra.rb
110
+ - lib/jdbc-helper/connector/mssql.rb
111
+ - lib/jdbc-helper/connector/mysql.rb
112
+ - lib/jdbc-helper/connector/oracle.rb
113
+ - lib/jdbc-helper/connector/postgresql.rb
114
+ - lib/jdbc-helper/constants.rb
115
+ - lib/jdbc-helper/sql.rb
116
+ - lib/jdbc-helper/sql/expression.rb
117
+ - lib/jdbc-helper/sql/sql.rb
118
+ - lib/jdbc-helper/sql/sql_prepared.rb
119
+ - lib/jdbc-helper/version.rb
120
+ - lib/jdbc-helper/wrapper/function_wrapper.rb
121
+ - lib/jdbc-helper/wrapper/object_wrapper.rb
122
+ - lib/jdbc-helper/wrapper/procedure_wrapper.rb
123
+ - lib/jdbc-helper/wrapper/sequence_wrapper.rb
124
+ - lib/jdbc-helper/wrapper/table_wrapper.rb
125
+ - test/database.yml
126
+ - test/helper.rb
127
+ - test/performance.rb
128
+ - test/test_connection.rb
129
+ - test/test_connectors.rb
130
+ - test/test_object_wrapper.rb
131
+ - test/test_sql.rb
132
+ - test/testrb
110
133
  homepage: https://github.com/junegunn/jdbc-helper
111
134
  licenses: []
112
-
113
- post_install_message:
135
+ post_install_message:
114
136
  rdoc_options: []
115
-
116
- require_paths:
117
- - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
119
144
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
124
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
125
150
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: "0"
130
151
  requirements: []
131
-
132
- rubyforge_project:
152
+ rubyforge_project:
133
153
  rubygems_version: 1.8.24
134
- signing_key:
154
+ signing_key:
135
155
  specification_version: 3
136
156
  summary: A JDBC helper for JRuby/Database developers.
137
- test_files:
138
- - test/database.yml
139
- - test/helper.rb
140
- - test/performance.rb
141
- - test/test_connection.rb
142
- - test/test_connectors.rb
143
- - test/test_object_wrapper.rb
144
- - test/test_sql.rb
145
- - test/testrb
157
+ test_files:
158
+ - test/database.yml
159
+ - test/helper.rb
160
+ - test/performance.rb
161
+ - test/test_connection.rb
162
+ - test/test_connectors.rb
163
+ - test/test_object_wrapper.rb
164
+ - test/test_sql.rb
165
+ - test/testrb
166
+ ...