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 +3 -0
- data/README.markdown +6 -6
- data/jdbc-helper.gemspec +1 -1
- data/lib/jdbc-helper/sql/expression.rb +1 -1
- data/lib/jdbc-helper/sql/sql.rb +3 -1
- data/lib/jdbc-helper/sql/sql_prepared.rb +2 -2
- data/lib/jdbc-helper/sql.rb +3 -0
- data/lib/jdbc-helper/version.rb +1 -1
- data/lib/jdbc-helper.rb +1 -3
- metadata +149 -128
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -249,11 +249,14 @@ table.drop!
|
|
249
249
|
|
250
250
|
#### Building complex where clauses
|
251
251
|
```ruby
|
252
|
-
|
252
|
+
# Shortcut. Or you can just include JDBCHelper
|
253
|
+
SQL = JDBCHelper::SQL
|
253
254
|
|
254
|
-
# With
|
255
|
+
# With any number of Strings, Arrays and Hashes
|
255
256
|
scope = table.where(
|
256
|
-
|
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', '
|
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
|
-
|
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]
|
data/lib/jdbc-helper/sql/sql.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/jdbc-helper/version.rb
CHANGED
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
|
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.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.7.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
|
9
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Junegunn Choi
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
85
|
+
email:
|
86
|
+
- junegunn.c@gmail.com
|
62
87
|
executables: []
|
63
|
-
|
64
88
|
extensions: []
|
65
|
-
|
66
89
|
extra_rdoc_files: []
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
+
...
|