gda 1.1.1 → 1.1.2

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
  SHA256:
3
- metadata.gz: 57c06ead700d0c7f320a74263ce3e5ecfe28015a5489d65d9f3c5faf96647709
4
- data.tar.gz: dad5b08bd24a8c61f2294b045a7b5a5c822a048ed94d1c82ebf8b63413c54b6d
3
+ metadata.gz: 552887449432426def5ab031502569f211e5a189202b6f2b548cc0fbd354f9e2
4
+ data.tar.gz: a590d4fa722c42553e2d95f79a1f825c91cf26ea234f6d2a2a5f44d06a57b9c2
5
5
  SHA512:
6
- metadata.gz: 1d734598fe06db00664019f84b15680499a48e4b54ee7512970009c84cfac4831bba103edf87539f2ae5e20bbbd433a9eeb730d16e0767651fdfa8e6f030612e
7
- data.tar.gz: 05f7689feb91287713fad9729d0af8b255ffa12c781892d1f3be5e84524b2853cd8492281d2dfeff8700ed14f78f87e02d60eba5075760439d6eca4bb6c775eb
6
+ metadata.gz: d392a3794b75a506bb2fd541cb0406ea23135d436f346be56d9974457abd06f7045b3bf6623798045fdc69e4424f9a1cd83eb8a1f065fa3a2a74726ef577379b
7
+ data.tar.gz: 7d2e04c3b9a1d0b3ecb311b68545870c51b048509133ed592da314528703a2b7e1ed0e3127e6661199ce2c35712e4c80beacd5e0cc722b2e5e05acba115f8b74
File without changes
@@ -7,7 +7,7 @@ static VALUE name(VALUE self)
7
7
  GdaServerProvider * pr;
8
8
  Data_Get_Struct(self, GdaServerProvider, pr);
9
9
 
10
- return rb_tainted_str_new2(gda_server_provider_get_name(pr));
10
+ return rb_str_new2(gda_server_provider_get_name(pr));
11
11
  }
12
12
 
13
13
  static VALUE find(VALUE klass, VALUE string)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GDA
4
+ VERSION = '1.1.2'
5
+ end
data/lib/gda.rb CHANGED
@@ -1,11 +1,9 @@
1
- require 'gda.so'
1
+ require 'gda/gda'
2
2
  require 'gda/visitors/each'
3
3
  require 'gda/visitors/dot'
4
4
  require 'gda/visitors/max_depth'
5
5
 
6
6
  module GDA
7
- VERSION = '1.1.1'
8
-
9
7
  module SQL
10
8
  class Statement
11
9
  def ast
metadata CHANGED
@@ -1,91 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gda
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: minitest
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.14'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.14'
27
- - !ruby/object:Gem::Dependency
28
- name: rake-compiler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.4.1
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 0.4.1
41
- - !ruby/object:Gem::Dependency
42
- name: sqlite3
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '4.0'
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: '7'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '4.0'
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: '7'
75
- - !ruby/object:Gem::Dependency
76
- name: hoe
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.23'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.23'
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
+ dependencies: []
89
13
  description: |-
90
14
  An SQL parser. Wraps libgda in a loving embrace to give you a ruby level SQL
91
15
  parser.
@@ -97,13 +21,10 @@ extensions:
97
21
  extra_rdoc_files:
98
22
  - CHANGELOG.rdoc
99
23
  - Manifest.txt
100
- - README.rdoc
101
24
  files:
102
- - ".autotest"
103
25
  - CHANGELOG.rdoc
104
26
  - Manifest.txt
105
- - README.rdoc
106
- - Rakefile
27
+ - README.md
107
28
  - ext/gda/extconf.rb
108
29
  - ext/gda/gda.c
109
30
  - ext/gda/gda.h
@@ -114,23 +35,15 @@ files:
114
35
  - ext/gda/gda_statement.c
115
36
  - ext/gda/gda_statement.h
116
37
  - lib/gda.rb
38
+ - lib/gda/version.rb
117
39
  - lib/gda/visitors/dot.rb
118
40
  - lib/gda/visitors/each.rb
119
41
  - lib/gda/visitors/max_depth.rb
120
42
  - lib/gda/visitors/visitor.rb
121
- - test/helper.rb
122
- - test/sqllog.sqlite3
123
- - test/test_dot_visitor.rb
124
- - test/test_gda.rb
125
- - test/test_max_depth.rb
126
- - test/test_node_attributes.rb
127
- - test/test_nodes.rb
128
- - test/test_statement.rb
129
43
  homepage: http://github.com/tenderlove/gda
130
44
  licenses:
131
45
  - MIT
132
- metadata:
133
- homepage_uri: http://github.com/tenderlove/gda
46
+ metadata: {}
134
47
  post_install_message:
135
48
  rdoc_options:
136
49
  - "--main"
@@ -141,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
54
  requirements:
142
55
  - - ">="
143
56
  - !ruby/object:Gem::Version
144
- version: 1.9.3
57
+ version: 2.5.0
145
58
  required_rubygems_version: !ruby/object:Gem::Requirement
146
59
  requirements:
147
60
  - - ">="
148
61
  - !ruby/object:Gem::Version
149
- version: '0'
62
+ version: 2.5.0
150
63
  requirements: []
151
- rubygems_version: 3.2.22
64
+ rubygems_version: 3.4.0.dev
152
65
  signing_key:
153
66
  specification_version: 4
154
67
  summary: An SQL parser
data/.autotest DELETED
@@ -1,12 +0,0 @@
1
- require "autotest/restart"
2
- require 'rbconfig'
3
-
4
- Autotest.add_hook :initialize do |at|
5
- at.find_directories = ARGV unless ARGV.empty?
6
- at.testlib = "minitest/autorun"
7
- end
8
-
9
- Autotest.add_hook :run_command do |at|
10
- at.unit_diff = 'cat'
11
- system "ruby -S rake compile"
12
- end
data/Rakefile DELETED
@@ -1,34 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.plugins.delete :rubyforge
7
- Hoe.plugin :minitest
8
- Hoe.plugin :gemspec # `gem install hoe-gemspec`
9
- Hoe.plugin :git # `gem install hoe-git`
10
-
11
- Hoe.spec 'gda' do
12
- developer('Aaron Patterson', 'tenderlove@ruby-lang.org')
13
- self.readme_file = 'README.rdoc'
14
- self.history_file = 'CHANGELOG.rdoc'
15
- self.extra_rdoc_files = FileList['*.rdoc']
16
-
17
- extra_dev_deps << ['rake-compiler', '>= 0.4.1']
18
- extra_dev_deps << ['sqlite3']
19
-
20
- self.spec_extras = {
21
- :extensions => ["ext/gda/extconf.rb"],
22
- :required_ruby_version => '>= 1.9.3'
23
- }
24
-
25
- require "rake/extensiontask"
26
-
27
- Rake::ExtensionTask.new "gda", spec do |ext|
28
- ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
29
- end
30
- end
31
-
32
- task :test => :compile
33
-
34
- # vim: syntax=ruby
data/test/helper.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'gda'
3
- require 'sqlite3'
4
-
5
- module GDA
6
- class TestCase < Minitest::Test
7
- @@rails_sql = nil
8
-
9
- def self.rails_sql
10
- return @@rails_sql if @@rails_sql
11
-
12
- db_file = File.join File.dirname(__FILE__), 'sqllog.sqlite3'
13
- db = SQLite3::Database.new db_file
14
- @@rails_sql = db.execute('SELECT * FROM sqllog').map(&:first)
15
- end
16
- end
17
- end
data/test/sqllog.sqlite3 DELETED
Binary file
@@ -1,43 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- class TestDotVisitor < TestCase
5
- attr_reader :parser
6
-
7
- class TestViz < Visitors::Dot
8
- def initialize tc
9
- super()
10
- @tc = tc
11
- end
12
-
13
- Visitors::Visitor.private_instance_methods.grep(/^visit_(.*)/) do |method|
14
- next if superclass.private_instance_methods(false).include?(method)
15
-
16
- klass = $1.split('_').inject(Object) { |k,c| k.const_get c }
17
-
18
- define_method(method) do |node|
19
- flunk "#{klass} (#{method}) not tested yet"
20
- end
21
- end
22
-
23
- def method_missing m, *args
24
- return super unless @tc.respond_to?(m)
25
-
26
- @tc.send m, *args
27
- end
28
- end
29
-
30
- def setup
31
- super
32
- @parser = GDA::SQL::Parser.new
33
- @viz = TestViz.new(self)
34
- end
35
-
36
- rails_sql.uniq.each do |sql|
37
- define_method(:"test_#{sql}") do
38
- stmt = parser.parse sql
39
- @viz.accept stmt.ast
40
- end
41
- end
42
- end
43
- end
data/test/test_gda.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- class TestParser < TestCase
5
- attr_reader :parser
6
-
7
- def setup
8
- super
9
- @parser = GDA::SQL::Parser.new
10
- end
11
-
12
- def test_split
13
- assert_equal ['test', '"table"'], GDA.sql_identifier_split("test.\"table\"")
14
- end
15
-
16
- def test_parses
17
- assert parser.parse('SELECT * FROM FOO')
18
- end
19
-
20
- def test_providers
21
- assert_kind_of Array, GDA::SQL.providers
22
- assert_operator GDA::SQL.providers.length, :>, 0
23
- end
24
-
25
- def test_get_provider
26
- assert GDA::SQL::Provider.find SQL.providers.first
27
- end
28
-
29
- def test_provider_name
30
- name = SQL.providers.first
31
- provider = SQL::Provider.find name
32
- assert_equal name, provider.name
33
- end
34
-
35
- def test_pg_parser
36
- provider = SQL::Provider.find "PostgreSQL"
37
- skip "don't have PG provider" unless provider
38
- assert provider.parser.parse 'INSERT INTO "accounts" ("credit_limit", "firm_id", "firm_name") VALUES ($1, $2, $3) RETURNING "id"'
39
- end
40
-
41
- def test_mysql_parser
42
- provider = SQL::Provider.find "MySQL"
43
- skip "don't have MySQL provider" unless provider
44
- assert provider.parser.parse 'SELECT topics.* FROM topics WHERE topics.id = 147 LIMIT 1'
45
-
46
- end
47
-
48
- def test_id_quote
49
- provider = SQL::Provider.find "MySQL"
50
- skip "don't have MySQL provider" unless provider
51
- assert_equal '"1foo"', provider.quote("1foo")
52
- end
53
-
54
- def test_error
55
- assert_nil SQL::Provider.find "asdfasdfadsf"
56
- end
57
- end
58
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- module Visitors
5
- class TestMaxDepth < TestCase
6
- attr_reader :parser
7
-
8
- def setup
9
- super
10
- @parser = GDA::SQL::Parser.new
11
- end
12
-
13
- def test_depth
14
- stmt = parser.parse('SELECT * FROM FOO')
15
- assert_equal 5, stmt.ast.max_depth
16
- end
17
- end
18
- end
19
- end
@@ -1,159 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- class TestNodeAttributes < TestCase
5
- attr_reader :parser
6
-
7
- class AttributeTest < Visitors::Visitor
8
- def initialize tc
9
- @tc = tc
10
- end
11
-
12
- private
13
-
14
- def visit_Array node
15
- node.each { |n| accept n }
16
- end
17
-
18
- def visit_GDA_Nodes_Select node
19
- assert_respond_to node, :distinct?
20
- super
21
- end
22
-
23
- def visit_GDA_Nodes_Unknown node
24
- super
25
- end
26
-
27
- def visit_GDA_Nodes_Insert node
28
- assert_string node, :on_conflict
29
- super
30
- end
31
-
32
- def visit_GDA_Nodes_SelectField node
33
- [:field_name, :table_name, :as].each do |m|
34
- assert_string node, m
35
- end
36
- super
37
- end
38
-
39
- def visit_GDA_Nodes_Expr node
40
- assert_string node, :value
41
- assert_string node, :cast_as
42
- super
43
- end
44
-
45
- def visit_GDA_Nodes_Function node
46
- assert_string node, :function_name
47
- super
48
- end
49
-
50
- def visit_GDA_Nodes_From node
51
- super
52
- end
53
-
54
- def visit_GDA_Nodes_Table node
55
- assert_string node, :table_name
56
- super
57
- end
58
-
59
- def visit_GDA_Nodes_Update node
60
- assert_string node, :on_conflict
61
- super
62
- end
63
-
64
- def visit_GDA_Nodes_Operation node
65
- assert_string node, :operator
66
- super
67
- end
68
-
69
- def visit_GDA_Nodes_Delete node
70
- super
71
- end
72
-
73
- def visit_GDA_Nodes_Order node
74
- assert_boolean node, :asc
75
- assert_string node, :collation_name
76
- super
77
- end
78
-
79
- def visit_GDA_Nodes_RollbackSavepoint node
80
- assert_string node, :__type__
81
- assert_string node, :isolation_level
82
- assert_string node, :trans_mode
83
- assert_string node, :trans_name
84
- super
85
- end
86
-
87
- alias :visit_GDA_Nodes_Begin :visit_GDA_Nodes_RollbackSavepoint
88
- alias :visit_GDA_Nodes_Savepoint :visit_GDA_Nodes_RollbackSavepoint
89
- alias :visit_GDA_Nodes_DeleteSavepoint :visit_GDA_Nodes_RollbackSavepoint
90
- alias :visit_GDA_Nodes_Commit :visit_GDA_Nodes_RollbackSavepoint
91
- alias :visit_GDA_Nodes_Rollback :visit_GDA_Nodes_RollbackSavepoint
92
-
93
- def visit_GDA_Nodes_Field node
94
- assert_string node, :field_name
95
- super
96
- end
97
-
98
- def visit_GDA_Nodes_Join node
99
- assert_string node, :join_type
100
- assert_int node, :position
101
- super
102
- end
103
-
104
- def visit_GDA_Nodes_Target node
105
- assert_string node, :table_name
106
- assert_string node, :as
107
- super
108
- end
109
-
110
- def assert_boolean node, m
111
- assert_respond_to node, m
112
- if node.send(m)
113
- assert_equal(true, node.send(m))
114
- else
115
- assert_equal(false, node.send(m))
116
- end
117
- end
118
-
119
- def assert_string node, m
120
- assert_respond_to node, m
121
- assert_kind_of(String, node.send(m)) if node.send(m)
122
- end
123
-
124
- def assert_int node, m
125
- assert_respond_to node, m
126
- assert_kind_of(Numeric, node.send(m)) if node.send(m)
127
- end
128
-
129
- Visitors::Visitor.private_instance_methods.grep(/^visit_(.*)/) do |method|
130
- next if private_instance_methods(false).include?(method)
131
-
132
- klass = $1.split('_').inject(Object) { |k,c| k.const_get c }
133
-
134
- define_method(method) do |node|
135
- flunk "#{klass} (#{method}) not tested yet"
136
- end
137
- end
138
-
139
- def method_missing m, *args
140
- return super unless @tc.respond_to?(m)
141
-
142
- @tc.send m, *args
143
- end
144
- end
145
-
146
- def setup
147
- super
148
- @parser = GDA::SQL::Parser.new
149
- @attr_tester = AttributeTest.new(self)
150
- end
151
-
152
- rails_sql.uniq.each do |sql|
153
- define_method(:"test_#{sql}") do
154
- stmt = parser.parse sql
155
- @attr_tester.accept stmt.ast
156
- end
157
- end
158
- end
159
- end
data/test/test_nodes.rb DELETED
@@ -1,31 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- class TestNodes < TestCase
5
- attr_reader :parser
6
-
7
- def setup
8
- super
9
- @parser = GDA::SQL::Parser.new
10
- end
11
-
12
- rails_sql.uniq.each do |sql|
13
- define_method(:"test_#{sql}") do
14
- stmt = parser.parse sql
15
- stmt.ast.each do |node|
16
- assert node
17
- end
18
- end
19
- end
20
-
21
- def test_depth
22
- stmt = parser.parse 'SELECT * FROM OMG WHERE 1 = 10'
23
- assert_operator stmt.ast.to_a.length, :>, 1
24
- end
25
-
26
- def test_not_equal_operator
27
- stmt = parser.parse 'SELECT id FROM comments WHERE issue_id = 1 AND type <> 3'
28
- assert stmt.ast.is_a?(GDA::Nodes::Select)
29
- end
30
- end
31
- end
@@ -1,112 +0,0 @@
1
- require 'helper'
2
-
3
- module GDA
4
- module SQL
5
- class TestUnion < TestCase
6
- attr_reader :parser, :stmt
7
-
8
- def setup
9
- @parser = GDA::SQL::Parser.new
10
- sql = <<-SQL.gsub(/^ */, "")
11
- SELECT id FROM posts WHERE actor_id = 1 AND actor_type = 1
12
- UNION
13
- SELECT id FROM posts WHERE actor_id = 1 AND actor_type = 3
14
- SQL
15
-
16
- @stmt = parser.parse(sql)
17
- end
18
-
19
- def test_union_query
20
- assert_equal 2, stmt.ast.stmt_list.count
21
- assert_equal 0, stmt.ast.compound_type, "should be an UNION type"
22
- end
23
-
24
- def test_union_query_visitor
25
- visitor = Class.new(Visitors::Visitor) do
26
- attr_reader :selects_count
27
- def visit_GDA_Nodes_Select(*)
28
- @selects_count ||= 0
29
- @selects_count += 1
30
- end
31
- end.new
32
-
33
- visitor.accept stmt.ast
34
- assert_equal 2, visitor.selects_count
35
- end
36
- end
37
-
38
- class TestStatement < TestCase
39
- attr_reader :parser, :stmt
40
-
41
- def setup
42
- super
43
- @parser = GDA::SQL::Parser.new
44
- @stmt = parser.parse 'SELECT * FROM FOO WHERE 1 = 1 GROUP BY omg HAVING omg(id) < 2 ORDER BY foo, bar LIMIT 50 OFFSET 2'
45
- end
46
-
47
- def test_serialize
48
- assert stmt.serialize
49
- end
50
-
51
- def test_from
52
- assert stmt.ast
53
- assert stmt.ast.from
54
- end
55
-
56
- def test_distinct_expr
57
- assert_nil stmt.ast.distinct_expr
58
- end
59
-
60
- def test_expr_list
61
- assert_equal 1, stmt.ast.expr_list.length
62
-
63
- stmt.ast.expr_list.each do |node|
64
- assert node
65
- end
66
- end
67
-
68
- def test_where_cond
69
- assert stmt.ast.where_cond
70
- end
71
-
72
- def test_group_by
73
- assert stmt.ast.group_by
74
- stmt.ast.group_by.each do |node|
75
- assert node
76
- end
77
- end
78
-
79
- def test_having_cond
80
- assert stmt.ast.having_cond
81
- end
82
-
83
- def test_order_by
84
- assert_equal 2, stmt.ast.order_by.length
85
- stmt.ast.order_by.each do |node|
86
- assert node
87
- end
88
- end
89
-
90
- def test_limit_count
91
- assert stmt.ast.limit_count
92
- end
93
-
94
- def test_limit_offset
95
- assert stmt.ast.limit_offset
96
- end
97
-
98
- def test_distinct?
99
- refute stmt.ast.distinct?
100
- end
101
-
102
- def test_each
103
- yielded = false
104
- stmt.ast.each do |node|
105
- yielded = true
106
- assert node
107
- end
108
- assert yielded
109
- end
110
- end
111
- end
112
- end