oracle-sql-parser 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d6c10d39c8d0989988d45e58feeb0e5e72e73d5
4
- data.tar.gz: 4a7b76b8f73c5d76eafb80017f186d8b91f5cb16
3
+ metadata.gz: e8298f6ea76a3b8ad33bbdaa2ee4c2d8055a266c
4
+ data.tar.gz: 6bf031d20d4ee9d2718d6c17d6ca4f9abfce4a6e
5
5
  SHA512:
6
- metadata.gz: c0dd268d036d3351d8d07fd112f8af285d6f64912efcd0f93105ed7a040ffe4019bd59cbb974cb369aacb9e6ee54d286be91b6f4bd3f30581be07c33271dabee
7
- data.tar.gz: 365786271e19e2492e83902b75a4664fc51f0de6badd606867b9dc87558d70e7b99e7e5dfaded0b93747e85ea89ef6b2c956bbd5a24e6f89d1d8b5855715d623
6
+ metadata.gz: 4bed5224575dc5ab3873878f843d93bcd1568232b52bc9b8f11193c72281b73f0561b4da16833d27c1014560331391c956c4d7a5b0ca77a6f66c67d7481a7100
7
+ data.tar.gz: 9f1a55461fc0aa234fb01a1503217c61648ddf00ae8e9dd1781fe37ea96e9337dd2176dbbe8c767b0dab5c23f0f68ee6032e812807d1e7805976e32c22f547f2
data/.gitignore CHANGED
@@ -16,5 +16,6 @@ lib/oracle-sql-parser/grammar/reserved_word.rb
16
16
  lib/oracle-sql-parser/grammar/reserved_word.treetop
17
17
  lib/oracle-sql-parser/grammar/select.rb
18
18
  lib/oracle-sql-parser/grammar/update.rb
19
+ test/oracle_enhanced-adapter/connection_params.yml
19
20
  *.sw?
20
21
  *.gem
data/HISTORY.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.6.0
2
+ * Enchancement
3
+ * added travis-ci
4
+ * added oracle enhanced adapter query(select, includes, joins, where)
5
+ * added syntax for column_alias
6
+
1
7
  ### 0.5.1
2
8
  * Bug fix
3
9
  * fix spell. to_pameternized is deprecated and will be removed. use to_parameterized
data/Rakefile CHANGED
@@ -35,6 +35,8 @@ Rake::TestTask.new do |t|
35
35
  'test/ast/replace_literal_test.rb',
36
36
  'test/ast/number_literal_test.rb',
37
37
  'test/ast/text_literal_test.rb',
38
+ 'test/ast/text_literal_test.rb',
39
+ 'test/oracle_enhanced-adapter/select_test.rb'
38
40
  ]
39
41
  t.verbose = true
40
42
  end
@@ -1,7 +1,7 @@
1
1
  module OracleSqlParser::Ast
2
- class CompoundCondition < Base
2
+ class CompoundCondition < Hash
3
3
  def to_sql(options = {})
4
- "(#{@ast.to_sql})"
4
+ "(#{@ast[:condition].to_sql})"
5
5
  end
6
6
  end
7
7
  end
@@ -47,6 +47,10 @@ module OracleSqlParser::Ast
47
47
  self.new(value)
48
48
  end
49
49
 
50
+ def []=(name, value)
51
+ @ast[name] = value
52
+ end
53
+
50
54
  def method_missing(name, *args)
51
55
  return @ast.send(:[], name) if @ast.has_key? name
52
56
  raise "no method:#{name}, #{@ast.class} in #{self.class}"
@@ -9,11 +9,15 @@ module OracleSqlParser::Ast
9
9
  end
10
10
 
11
11
  def to_sql(options = {})
12
+ result = []
12
13
  if quoted?
13
- "\"#{@ast[:name]}\""
14
+ result << "\"#{@ast[:name]}\""
14
15
  else
15
- @ast[:name]
16
+ result << @ast[:name]
16
17
  end
18
+ result << @ast[:as] if @ast[:as]
19
+ result << @ast[:alias] if @ast[:alias]
20
+ result.map(&:to_sql).join(' ')
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  module OracleSqlParser::Ast
2
- class SearchedCaseExpression < Base
2
+ class SearchedCaseExpression < Hash
3
3
  def else_clause=(ast)
4
4
  @ast[:else_clause] = ast
5
5
  end
@@ -251,7 +251,7 @@ module OracleSqlParser::Grammar
251
251
  rule compound_condition
252
252
  '(' logical_condition ')' {
253
253
  def ast
254
- OracleSqlParser::Ast::CompoundCondition[logical_condition.ast]
254
+ OracleSqlParser::Ast::CompoundCondition[:condition => logical_condition.ast]
255
255
  end
256
256
  }
257
257
  end
@@ -1,20 +1,26 @@
1
1
  module OracleSqlParser::Grammar
2
2
  grammar Expression
3
3
  rule sql_expression
4
- function_expression /
5
- case_expression /
6
- cursor_expression /
7
- compound_expression /
8
- datetime_expression /
9
- interval_expression /
10
- object_access_expression /
11
- scalar_subquery_expression /
12
- model_expression /
13
- type_constructor_expression /
14
- simple_expression /
15
- variable_expression {
16
- def ast
17
- super
4
+ ex:(
5
+ function_expression /
6
+ case_expression /
7
+ cursor_expression /
8
+ compound_expression /
9
+ datetime_expression /
10
+ interval_expression /
11
+ object_access_expression /
12
+ scalar_subquery_expression /
13
+ model_expression /
14
+ type_constructor_expression /
15
+ simple_expression /
16
+ variable_expression)
17
+ alias_name:(space as_keyword space ident)?
18
+ {
19
+ def ast
20
+ tree = ex.ast
21
+ tree[:as] = alias_name.try(:as_keyword).try(:ast)
22
+ tree[:alias] = alias_name.try(:ident).try(:ast)
23
+ tree
18
24
  end
19
25
  }
20
26
  end
@@ -1,3 +1,3 @@
1
1
  module OracleSqlParser
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/jksy/sql_parser"
15
15
  spec.licenses = ["MIT"]
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/|.travis}) }
18
18
  spec.files += `echo lib/oracle-sql-parser/grammar/*.rb`.split(" ")
19
19
  spec.require_paths = ["lib"]
20
20
 
@@ -23,4 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.10"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "test-unit", "~> 3.1"
26
+ spec.add_development_dependency "activerecord", "~> 4.2"
27
+ spec.add_development_dependency "activerecord-oracle_enhanced-adapter", "~> 1.6.0"
28
+ spec.add_development_dependency "ruby-oci8", "~> 2.0"
26
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oracle-sql-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junichiro Kasuya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -66,6 +66,48 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord-oracle_enhanced-adapter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-oci8
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
69
111
  description: SQL Parser for Oracle
70
112
  email:
71
113
  - junichiro.kasuya@gmail.com
@@ -74,7 +116,6 @@ extensions: []
74
116
  extra_rdoc_files: []
75
117
  files:
76
118
  - ".gitignore"
77
- - ".travis.yml"
78
119
  - Gemfile
79
120
  - HISTORY.md
80
121
  - README.md
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.2.2
5
- before_install: gem install bundler -v 1.10.5
6
- script:
7
- - rake gen_force
8
- - rake test