fluent-query-dbi 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "fluent-query-sql", ">= 0.9.0"
5
- gem "fluent-query", ">= 0.9.0"
4
+ gem "fluent-query-sql", ">= 0.9.2"
5
+ gem "fluent-query", ">= 0.9.2"
6
6
  gem "abstract", ">= 1.0.0"
7
7
  gem "hash-utils", ">= 0.18.0"
8
8
  gem "dbi", ">= 0.4.5"
@@ -11,12 +11,5 @@ source "http://rubygems.org"
11
11
  # Include everything needed to run rake, tests, features, etc.
12
12
  group :development do
13
13
  gem "bundler", ">= 1.0.13"
14
- gem "jeweler", ">= 1.6.0"
14
+ gem "jeweler2", ">= 2.0.0"
15
15
  end
16
-
17
- # fluent-query-sql
18
- # fluent-query-dbh
19
- # fluent-query-mysql
20
- # fluent-query-sqlite
21
- # fluent-query-postgresql
22
- # native-query
@@ -5,22 +5,19 @@ GEM
5
5
  dbi (0.4.5)
6
6
  deprecated (= 2.0.1)
7
7
  deprecated (2.0.1)
8
- fluent-query (0.9.1)
8
+ fluent-query (0.9.3)
9
9
  abstract (>= 1.0.0)
10
10
  hash-utils (>= 0.18.0)
11
- hashie (>= 1.0.0)
12
- fluent-query-sql (0.9.1)
11
+ fluent-query-sql (0.9.2)
13
12
  abstract (>= 1.0.0)
14
- fluent-query (>= 0.9.0)
13
+ fluent-query (>= 0.9.2)
15
14
  hash-utils (>= 0.18.0)
16
15
  git (1.2.5)
17
- hash-utils (0.18.0)
18
- hashie (1.0.0)
19
- jeweler (1.6.3)
20
- bundler (~> 1.0)
16
+ hash-utils (2.0.0)
17
+ ruby-version
18
+ jeweler2 (2.0.9)
21
19
  git (>= 1.2.5)
22
- rake
23
- rake (0.9.2)
20
+ ruby-version (0.3.1)
24
21
 
25
22
  PLATFORMS
26
23
  ruby
@@ -29,7 +26,7 @@ DEPENDENCIES
29
26
  abstract (>= 1.0.0)
30
27
  bundler (>= 1.0.13)
31
28
  dbi (>= 0.4.5)
32
- fluent-query (>= 0.9.0)
33
- fluent-query-sql (>= 0.9.0)
29
+ fluent-query (>= 0.9.2)
30
+ fluent-query-sql (>= 0.9.2)
34
31
  hash-utils (>= 0.18.0)
35
- jeweler (>= 1.6.0)
32
+ jeweler2 (>= 2.0.0)
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 - 2011 Martin Kozák (martinkozak@martinkozak.net)
1
+ Copyright (c) 2009 - 2012 Martin Kozák (martinkozak@martinkozak.net)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -23,7 +23,7 @@ Contributing
23
23
  Copyright
24
24
  ---------
25
25
 
26
- Copyright © 2009-2011 [Martin Kozák][3]. See `LICENSE.txt` for
26
+ Copyright © 2009-2012 [Martin Kozák][3]. See `LICENSE.txt` for
27
27
  further details.
28
28
 
29
29
  [2]: http://github.com/martinkozak/fluent-query-dbi/issues
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
 
13
13
  require 'rake'
14
- require 'jeweler'
14
+ require 'jeweler2'
15
15
 
16
16
  Jeweler::Tasks.new do |gem|
17
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{fluent-query-dbi}
8
- s.version = "0.9.1"
7
+ s.name = "fluent-query-dbi"
8
+ s.version = "0.9.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Martin Kozák}]
12
- s.date = %q{2011-07-15}
13
- s.email = %q{martinkozak@martinkozak.net}
11
+ s.authors = ["Martin Koz\u{e1}k"]
12
+ s.date = "2012-05-30"
13
+ s.email = "martinkozak@martinkozak.net"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
16
16
  "README.md"
@@ -28,40 +28,40 @@ Gem::Specification.new do |s|
28
28
  "lib/fluent-query/drivers/dbi/prepared.rb",
29
29
  "lib/fluent-query/drivers/shared/results/dbi.rb"
30
30
  ]
31
- s.homepage = %q{http://github.com/martinkozak/fluent-query-dbi}
32
- s.licenses = [%q{MIT}]
33
- s.require_paths = [%q{lib}]
34
- s.rubygems_version = %q{1.8.5}
35
- s.summary = %q{Generic DBI support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby. Contains base libraries used by specific SQL driver.}
31
+ s.homepage = "http://github.com/martinkozak/fluent-query-dbi"
32
+ s.licenses = ["MIT"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.24"
35
+ s.summary = "Generic DBI support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby. Contains base libraries used by specific SQL driver."
36
36
 
37
37
  if s.respond_to? :specification_version then
38
38
  s.specification_version = 3
39
39
 
40
40
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- s.add_runtime_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
42
- s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.0"])
41
+ s.add_runtime_dependency(%q<fluent-query-sql>, [">= 0.9.2"])
42
+ s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.2"])
43
43
  s.add_runtime_dependency(%q<abstract>, [">= 1.0.0"])
44
44
  s.add_runtime_dependency(%q<hash-utils>, [">= 0.18.0"])
45
45
  s.add_runtime_dependency(%q<dbi>, [">= 0.4.5"])
46
46
  s.add_development_dependency(%q<bundler>, [">= 1.0.13"])
47
- s.add_development_dependency(%q<jeweler>, [">= 1.6.0"])
47
+ s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
48
48
  else
49
- s.add_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
50
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
49
+ s.add_dependency(%q<fluent-query-sql>, [">= 0.9.2"])
50
+ s.add_dependency(%q<fluent-query>, [">= 0.9.2"])
51
51
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
52
52
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
53
53
  s.add_dependency(%q<dbi>, [">= 0.4.5"])
54
54
  s.add_dependency(%q<bundler>, [">= 1.0.13"])
55
- s.add_dependency(%q<jeweler>, [">= 1.6.0"])
55
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
56
56
  end
57
57
  else
58
- s.add_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
59
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
58
+ s.add_dependency(%q<fluent-query-sql>, [">= 0.9.2"])
59
+ s.add_dependency(%q<fluent-query>, [">= 0.9.2"])
60
60
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
61
61
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
62
62
  s.add_dependency(%q<dbi>, [">= 0.4.5"])
63
63
  s.add_dependency(%q<bundler>, [">= 1.0.13"])
64
- s.add_dependency(%q<jeweler>, [">= 1.6.0"])
64
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
65
65
  end
66
66
  end
67
67
 
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "abstract"
3
- require "hash-utils/object" # >= 0.17.0
4
- require "hash-utils/array"
5
- require "hash-utils/hash"
3
+ require "hash-utils" # >= 0.17.0
6
4
 
7
5
  require "fluent-query/drivers/sql"
8
6
  require "fluent-query/drivers/exception"
@@ -32,6 +30,24 @@ module FluentQuery
32
30
  super(connection)
33
31
  end
34
32
 
33
+ ##
34
+ # Indicates, method is relevant for the driver.
35
+ #
36
+ # @since 0.9.2
37
+ # @abstract
38
+ #
39
+
40
+ public
41
+ def relevant_method?(name)
42
+ if name.start_with? "prepare_"
43
+ _name = name[8..-1].to_sym
44
+ else
45
+ _name = name
46
+ end
47
+
48
+ super(_name)
49
+ end
50
+
35
51
  ##
36
52
  # Returns preparation placeholder.
37
53
  #
@@ -188,6 +204,67 @@ module FluentQuery
188
204
  def prepare(query)
189
205
  DBI::Prepared::new(self, query)
190
206
  end
207
+
208
+ ##
209
+ # Checks query conditionally. It's called after first token
210
+ # of the query.
211
+ #
212
+ # @see FluentQuery::Drivers::SQL#execute_conditionally
213
+ # @see #prepare_conditionally
214
+ # @since 0.9.2
215
+ #
216
+
217
+ public
218
+ def check_conditionally(query, sym, *args, &block)
219
+ if sym.start_with? "prepare_"
220
+ self.prepare_conditionally(query, sym, *args, &block)
221
+ else
222
+ super(query, sym, *args, &block)
223
+ end
224
+ end
225
+
226
+ ##
227
+ # Prepares query conditionally.
228
+ #
229
+ # If query isn't suitable for preparing, returns it. In otherwise
230
+ # returns +nil+, result or number of changed rows.
231
+ #
232
+ # @since 0.9.2
233
+ #
234
+
235
+ public
236
+ def prepare_conditionally(query, sym, *args, &block)
237
+ case query.type
238
+ when :insert
239
+ if (args.first.symbol?) and (args.second.hash?)
240
+ result = query.prepare!
241
+ end
242
+ when :truncate
243
+ if args.first.symbol?
244
+ result = query.prepare!
245
+ end
246
+ else
247
+ result = nil
248
+ end
249
+
250
+ return result
251
+ end
252
+
253
+ ##
254
+ # Corrects token before it's pushed to the token. So allows to
255
+ # modify data assigned to the query from driver level.
256
+ #
257
+ # @since 0.9.2
258
+ #
259
+
260
+ public
261
+ def correct_token(name, args)
262
+ if name.start_with? "prepare_"
263
+ name = name[8..-1].to_sym
264
+ end
265
+
266
+ return [name, args]
267
+ end
191
268
 
192
269
  end
193
270
  end
@@ -68,11 +68,11 @@ module FluentQuery
68
68
 
69
69
  def prepared
70
70
  if @prepared.nil?
71
- string = @driver.build_query(@query, :compile)
71
+ string = @driver.build_query(@query, :prepare)
72
72
  string.gsub!(self.matcher, '?\1')
73
73
  @prepared = string
74
74
  end
75
-
75
+ #p @prepared
76
76
  @prepared
77
77
  end
78
78
 
@@ -29,6 +29,12 @@ module FluentQuery
29
29
  protected
30
30
  @@_sources = { }
31
31
 
32
+ ##
33
+ # Holds column names cache.
34
+ #
35
+
36
+ @@column_names = nil
37
+
32
38
  ##
33
39
  # Initializes result.
34
40
  #
@@ -72,9 +78,10 @@ module FluentQuery
72
78
  public
73
79
  def one
74
80
  row = @_source.fetch_hash
75
-
81
+
76
82
  if row
77
- result = FluentQuery::Data[row]
83
+ row = row.map_keys { |i| i.to_sym }
84
+ result = FluentQuery::Data::new(row)
78
85
  else
79
86
  result = nil
80
87
  end
@@ -126,6 +133,19 @@ module FluentQuery
126
133
  def each(&block)
127
134
  self.hash &block
128
135
  end
136
+
137
+ ##
138
+ # Returns the column names.
139
+ #
140
+
141
+ public
142
+ def column_names
143
+ if @@column_names.nil?
144
+ @@column_names = @_source.column_names.map { |i| i.to_sym }
145
+ end
146
+
147
+ @@column_names
148
+ end
129
149
 
130
150
  ##
131
151
  # Repeats the query leaded to the result.
@@ -133,8 +153,8 @@ module FluentQuery
133
153
 
134
154
  public
135
155
  def repeat!
136
- @_source.execute
137
- return self
156
+ @_source.execute()
157
+ self
138
158
  end
139
159
 
140
160
  ##
metadata CHANGED
@@ -1,104 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fluent-query-dbi
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
4
5
  prerelease:
5
- version: 0.9.1
6
6
  platform: ruby
7
- authors:
8
- - "Martin Koz\xC3\xA1k"
7
+ authors:
8
+ - Martin Kozák
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: fluent-query-sql
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.9.0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2
30
+ - !ruby/object:Gem::Dependency
27
31
  name: fluent-query
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.9.0
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.2
34
38
  type: :runtime
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.2
46
+ - !ruby/object:Gem::Dependency
38
47
  name: abstract
39
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
40
49
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
44
53
  version: 1.0.0
45
54
  type: :runtime
46
55
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
49
63
  name: hash-utils
50
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
51
65
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
55
69
  version: 0.18.0
56
70
  type: :runtime
57
71
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.18.0
78
+ - !ruby/object:Gem::Dependency
60
79
  name: dbi
61
- requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
62
81
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
66
85
  version: 0.4.5
67
86
  type: :runtime
68
87
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 0.4.5
94
+ - !ruby/object:Gem::Dependency
71
95
  name: bundler
72
- requirement: &id006 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
73
97
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
77
101
  version: 1.0.13
78
102
  type: :development
79
103
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: jeweler
83
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
84
105
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: 1.6.0
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.13
110
+ - !ruby/object:Gem::Dependency
111
+ name: jeweler2
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.0.0
89
118
  type: :development
90
119
  prerelease: false
91
- version_requirements: *id007
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 2.0.0
92
126
  description:
93
127
  email: martinkozak@martinkozak.net
94
128
  executables: []
95
-
96
129
  extensions: []
97
-
98
- extra_rdoc_files:
130
+ extra_rdoc_files:
99
131
  - LICENSE.txt
100
132
  - README.md
101
- files:
133
+ files:
102
134
  - .document
103
135
  - Gemfile
104
136
  - Gemfile.lock
@@ -111,34 +143,32 @@ files:
111
143
  - lib/fluent-query/drivers/dbi/prepared.rb
112
144
  - lib/fluent-query/drivers/shared/results/dbi.rb
113
145
  homepage: http://github.com/martinkozak/fluent-query-dbi
114
- licenses:
146
+ licenses:
115
147
  - MIT
116
148
  post_install_message:
117
149
  rdoc_options: []
118
-
119
- require_paths:
150
+ require_paths:
120
151
  - lib
121
- required_ruby_version: !ruby/object:Gem::Requirement
152
+ required_ruby_version: !ruby/object:Gem::Requirement
122
153
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: -1693757158765774675
127
- segments:
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ segments:
128
159
  - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
160
+ hash: -707879157469416614
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
162
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: "0"
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
136
167
  requirements: []
137
-
138
168
  rubyforge_project:
139
- rubygems_version: 1.8.5
169
+ rubygems_version: 1.8.24
140
170
  signing_key:
141
171
  specification_version: 3
142
- summary: Generic DBI support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby. Contains base libraries used by specific SQL driver.
172
+ summary: Generic DBI support for the Fluent Query. Fluent Query is cool way how to
173
+ write SQL queries in Ruby. Contains base libraries used by specific SQL driver.
143
174
  test_files: []
144
-