fluent-query-sql 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
@@ -3,20 +3,11 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  gem "hash-utils", ">= 0.18.0"
5
5
  gem "abstract", ">= 1.0.0"
6
- gem "fluent-query", ">= 0.9.0"
6
+ gem "fluent-query", ">= 0.9.2"
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
- gem "bundler", "~> 1.0.13"
12
- gem "jeweler", "~> 1.6.0"
11
+ gem "bundler", ">= 1.0.13"
12
+ gem "jeweler2", ">= 2.0.0"
13
13
  end
14
-
15
-
16
-
17
- # fluent-query-sql
18
- # fluent-query-dbh
19
- # fluent-query-mysql
20
- # fluent-query-sqlite
21
- # fluent-query-postgresql
22
- # native-query
@@ -2,25 +2,22 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- fluent-query (0.9.0)
5
+ fluent-query (0.9.3)
6
6
  abstract (>= 1.0.0)
7
7
  hash-utils (>= 0.18.0)
8
- hashie (>= 1.0.0)
9
8
  git (1.2.5)
10
- hash-utils (0.18.0)
11
- hashie (1.0.0)
12
- jeweler (1.6.3)
13
- bundler (~> 1.0)
9
+ hash-utils (2.0.0)
10
+ ruby-version
11
+ jeweler2 (2.0.9)
14
12
  git (>= 1.2.5)
15
- rake
16
- rake (0.9.2)
13
+ ruby-version (0.3.1)
17
14
 
18
15
  PLATFORMS
19
16
  ruby
20
17
 
21
18
  DEPENDENCIES
22
19
  abstract (>= 1.0.0)
23
- bundler (~> 1.0.13)
24
- fluent-query (>= 0.9.0)
20
+ bundler (>= 1.0.13)
21
+ fluent-query (>= 0.9.2)
25
22
  hash-utils (>= 0.18.0)
26
- jeweler (~> 1.6.0)
23
+ 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-sql/issues
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ rescue Bundler::BundlerError => e
12
12
  end
13
13
 
14
14
  require 'rake'
15
- require 'jeweler'
15
+ require 'jeweler2'
16
16
 
17
17
  Jeweler::Tasks.new do |gem|
18
18
  # 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-sql}
8
- s.version = "0.9.1"
7
+ s.name = "fluent-query-sql"
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-14}
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"
@@ -41,11 +41,11 @@ Gem::Specification.new do |s|
41
41
  "lib/fluent-query/drivers/sql.rb",
42
42
  "lib/fluent-query/queries/sql.rb"
43
43
  ]
44
- s.homepage = %q{http://github.com/martinkozak/fluent-query-sql}
45
- s.licenses = [%q{MIT}]
46
- s.require_paths = [%q{lib}]
47
- s.rubygems_version = %q{1.8.5}
48
- s.summary = %q{Generic SQL 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.}
44
+ s.homepage = "http://github.com/martinkozak/fluent-query-sql"
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = "1.8.24"
48
+ s.summary = "Generic SQL 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."
49
49
 
50
50
  if s.respond_to? :specification_version then
51
51
  s.specification_version = 3
@@ -53,22 +53,22 @@ Gem::Specification.new do |s|
53
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
54
  s.add_runtime_dependency(%q<hash-utils>, [">= 0.18.0"])
55
55
  s.add_runtime_dependency(%q<abstract>, [">= 1.0.0"])
56
- s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.0"])
57
- s.add_development_dependency(%q<bundler>, ["~> 1.0.13"])
58
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
56
+ s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.2"])
57
+ s.add_development_dependency(%q<bundler>, [">= 1.0.13"])
58
+ s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
59
59
  else
60
60
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
61
61
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
62
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
63
- s.add_dependency(%q<bundler>, ["~> 1.0.13"])
64
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
62
+ s.add_dependency(%q<fluent-query>, [">= 0.9.2"])
63
+ s.add_dependency(%q<bundler>, [">= 1.0.13"])
64
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
65
65
  end
66
66
  else
67
67
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
68
68
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
69
- s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
70
- s.add_dependency(%q<bundler>, ["~> 1.0.13"])
71
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
69
+ s.add_dependency(%q<fluent-query>, [">= 0.9.2"])
70
+ s.add_dependency(%q<bundler>, [">= 1.0.13"])
71
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
72
72
  end
73
73
  end
74
74
 
@@ -30,6 +30,7 @@ module FluentQuery
30
30
 
31
31
  # INSERT token
32
32
  if token.name == :insert
33
+ values = arguments.second.values
33
34
 
34
35
  # Checks for arguments
35
36
  if (not arguments.first.symbol?) or (not arguments.second.hash?)
@@ -39,7 +40,20 @@ module FluentQuery
39
40
  # Process
40
41
  table = processor.quote_identifier(arguments.first)
41
42
  fields = processor.process_identifiers(arguments.second.keys)
42
- values = processor.process_array(arguments.second.values)
43
+
44
+ if mode == :prepare
45
+ values = values.map do |item|
46
+ if item != ??
47
+ processor.quote_value(i)
48
+ else
49
+ item
50
+ end
51
+ end
52
+
53
+ values = values.join(', ')
54
+ else
55
+ values = processor.process_array(values)
56
+ end
43
57
 
44
58
  result << table << " (" << fields << ") VALUES (" << values << ")"
45
59
 
@@ -1,8 +1,10 @@
1
1
  # encoding: utf-8
2
+ require "set"
2
3
  require "abstract"
3
4
  require "hash-utils/module" # >= 0.13.0
4
5
  require "hash-utils/string" # >= 0.15.0
5
6
  require "hash-utils/array" # >= 0.17.0
7
+ require "hash-utils/object" # >= 0.8.0
6
8
 
7
9
  require "fluent-query/driver"
8
10
  require "fluent-query/queries/sql"
@@ -21,7 +23,7 @@ module FluentQuery
21
23
  # Contains relevant methods index for this driver.
22
24
  #
23
25
 
24
- RELEVANT = [:select, :insert, :update, :delete, :truncate, :set, :begin, :commit, :union, :rollback]
26
+ RELEVANT = Set::new [:select, :insert, :update, :delete, :truncate, :set, :begin, :commit, :union, :rollback]
25
27
 
26
28
  ##
27
29
  # Contains ordering for typicall queries.
@@ -67,7 +69,7 @@ module FluentQuery
67
69
  # Indicates, appropriate token should be present by one real token, but more input tokens.
68
70
  #
69
71
 
70
- AGREGATE = [:where, :orderBy, :select, :groupBy, :having]
72
+ AGREGATE = Set::new [:where, :orderBy, :select, :groupBy, :having]
71
73
 
72
74
  ##
73
75
  # Indicates token aliases.
@@ -153,12 +155,8 @@ module FluentQuery
153
155
  @ordering = SQL::ORDERING
154
156
  @operators = SQL::OPERATORS
155
157
  @aliases = SQL::ALIASES
158
+ @agregate = SQL::AGREGATE
156
159
 
157
- @agregate = { }
158
- SQL::AGREGATE.each do |i|
159
- @agregate[i] = true
160
- end
161
-
162
160
  @_tokens_required = { }
163
161
  end
164
162
 
@@ -170,7 +168,7 @@ module FluentQuery
170
168
 
171
169
  public
172
170
  def relevant_method?(name)
173
- @relevant.include? name
171
+ name.in? @relevant
174
172
  end
175
173
 
176
174
  ##
@@ -196,7 +194,7 @@ module FluentQuery
196
194
 
197
195
  return result
198
196
 
199
- end
197
+ end
200
198
 
201
199
  ##
202
200
  # Builds given query.
@@ -257,12 +255,12 @@ module FluentQuery
257
255
  ##
258
256
  # Indicates which query subclass to use.
259
257
  #
260
-
258
+
261
259
  public
262
260
  def query_class
263
261
  FluentQuery::Queries::SQL
264
262
  end
265
-
263
+
266
264
  ##
267
265
  # Builds given query.
268
266
  #
@@ -340,7 +338,7 @@ module FluentQuery
340
338
  if (name == :__init__) and (not subtokens.nil?)
341
339
  init_tokens = [inittoken_class::new(self, query, subtokens)]
342
340
 
343
- elsif @agregate.has_key? name
341
+ elsif name.in? @agregate
344
342
  agregates[name] << data
345
343
 
346
344
  elsif self.known_token? type, name
@@ -441,7 +439,7 @@ module FluentQuery
441
439
  string = string.gsub("'", "''")
442
440
  string.gsub!("\\", "\\\\\\\\")
443
441
 
444
- return "'" << string << "'"
442
+ return "'" + string + "'"
445
443
  end
446
444
 
447
445
  ##
@@ -468,7 +466,7 @@ module FluentQuery
468
466
 
469
467
  public
470
468
  def quote_identifier(field)
471
- '"' << field.to_s.gsub(".", '"."') << '"'
469
+ '"' + field.to_s.gsub(".", '"."') + '"'
472
470
  end
473
471
 
474
472
  ##
@@ -504,7 +502,7 @@ module FluentQuery
504
502
 
505
503
  public
506
504
  def quote_subquery(subquery)
507
- "(" << subquery << ")"
505
+ "(" + subquery + ")"
508
506
  end
509
507
 
510
508
 
@@ -521,12 +519,25 @@ module FluentQuery
521
519
  def open_connection(settings)
522
520
  not_implemented
523
521
  end
522
+
523
+ ##
524
+ # Checks query conditionally. It's called after first token
525
+ # of the query.
526
+ #
527
+ # @see #execute_conditionally
528
+ # @since 0.9.2
529
+ #
530
+
531
+ public
532
+ def check_conditionally(query, sym, *args, &block)
533
+ self.execute_conditionally(query, sym, *args, &block)
534
+ end
524
535
 
525
536
  ##
526
537
  # Executes query conditionally.
527
538
  #
528
539
  # If query isn't suitable for executing, returns it. In otherwise
529
- # returns result or number of changed rows.
540
+ # returns +nil+, result or number of changed rows.
530
541
  #
531
542
 
532
543
  public
@@ -36,7 +36,7 @@ module FluentQuery
36
36
  #
37
37
 
38
38
  def processor
39
- super()
39
+ super
40
40
  end
41
41
 
42
42
  ##
metadata CHANGED
@@ -1,82 +1,104 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fluent-query-sql
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-14 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: hash-utils
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
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
22
21
  version: 0.18.0
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.18.0
30
+ - !ruby/object:Gem::Dependency
27
31
  name: abstract
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
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
33
37
  version: 1.0.0
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: 1.0.0
46
+ - !ruby/object:Gem::Dependency
38
47
  name: fluent-query
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
44
- version: 0.9.0
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
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: 0.9.2
62
+ - !ruby/object:Gem::Dependency
49
63
  name: bundler
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: 1.0.13
56
70
  type: :development
57
71
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: jeweler
61
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.13
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler2
80
+ requirement: !ruby/object:Gem::Requirement
62
81
  none: false
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- version: 1.6.0
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 2.0.0
67
86
  type: :development
68
87
  prerelease: false
69
- version_requirements: *id005
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 2.0.0
70
94
  description:
71
95
  email: martinkozak@martinkozak.net
72
96
  executables: []
73
-
74
97
  extensions: []
75
-
76
- extra_rdoc_files:
98
+ extra_rdoc_files:
77
99
  - LICENSE.txt
78
100
  - README.md
79
- files:
101
+ files:
80
102
  - .document
81
103
  - Gemfile
82
104
  - Gemfile.lock
@@ -102,34 +124,32 @@ files:
102
124
  - lib/fluent-query/drivers/sql.rb
103
125
  - lib/fluent-query/queries/sql.rb
104
126
  homepage: http://github.com/martinkozak/fluent-query-sql
105
- licenses:
127
+ licenses:
106
128
  - MIT
107
129
  post_install_message:
108
130
  rdoc_options: []
109
-
110
- require_paths:
131
+ require_paths:
111
132
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
133
+ required_ruby_version: !ruby/object:Gem::Requirement
113
134
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: -3539152250720307305
118
- segments:
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ segments:
119
140
  - 0
120
- version: "0"
121
- required_rubygems_version: !ruby/object:Gem::Requirement
141
+ hash: -2953163305667929305
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
143
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: "0"
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
127
148
  requirements: []
128
-
129
149
  rubyforge_project:
130
- rubygems_version: 1.8.5
150
+ rubygems_version: 1.8.24
131
151
  signing_key:
132
152
  specification_version: 3
133
- summary: Generic SQL 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.
153
+ summary: Generic SQL support for the Fluent Query. Fluent Query is cool way how to
154
+ write SQL queries in Ruby. Contains base libraries used by specific SQL driver.
134
155
  test_files: []
135
-