activerecord-jdbc-alt-adapter 61.1.0-java → 70.0.0.rc1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +273 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +3 -4
  5. data/Gemfile +8 -6
  6. data/README.md +2 -1
  7. data/Rakefile +1 -1
  8. data/activerecord-jdbc-adapter.gemspec +2 -2
  9. data/activerecord-jdbc-alt-adapter.gemspec +2 -2
  10. data/lib/arel/visitors/compat.rb +5 -33
  11. data/lib/arel/visitors/h2.rb +1 -13
  12. data/lib/arel/visitors/hsqldb.rb +1 -21
  13. data/lib/arel/visitors/sql_server.rb +2 -103
  14. data/lib/arjdbc/abstract/core.rb +8 -9
  15. data/lib/arjdbc/abstract/database_statements.rb +4 -4
  16. data/lib/arjdbc/discover.rb +0 -67
  17. data/lib/arjdbc/hsqldb/adapter.rb +2 -2
  18. data/lib/arjdbc/jdbc/adapter.rb +3 -3
  19. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  20. data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
  21. data/lib/arjdbc/jdbc/column.rb +1 -26
  22. data/lib/arjdbc/jdbc/type_cast.rb +2 -2
  23. data/lib/arjdbc/jdbc.rb +0 -7
  24. data/lib/arjdbc/mssql/adapter.rb +134 -105
  25. data/lib/arjdbc/mssql/quoting.rb +26 -27
  26. data/lib/arjdbc/mssql/schema_creation.rb +1 -1
  27. data/lib/arjdbc/mssql/schema_definitions.rb +32 -17
  28. data/lib/arjdbc/mssql/schema_dumper.rb +13 -1
  29. data/lib/arjdbc/mssql/schema_statements.rb +61 -36
  30. data/lib/arjdbc/mssql/transaction.rb +2 -2
  31. data/lib/arjdbc/mssql/types/date_and_time_types.rb +6 -6
  32. data/lib/arjdbc/mssql/types/numeric_types.rb +2 -2
  33. data/lib/arjdbc/mssql.rb +1 -1
  34. data/lib/arjdbc/mysql/adapter.rb +2 -1
  35. data/lib/arjdbc/oracle/adapter.rb +4 -23
  36. data/lib/arjdbc/postgresql/adapter.rb +64 -1
  37. data/lib/arjdbc/postgresql/oid_types.rb +68 -47
  38. data/lib/arjdbc/sqlite3/adapter.rb +132 -88
  39. data/lib/arjdbc/tasks/database_tasks.rb +0 -12
  40. data/lib/arjdbc/util/serialized_attributes.rb +0 -22
  41. data/lib/arjdbc/util/table_copier.rb +2 -1
  42. data/lib/arjdbc/version.rb +1 -1
  43. data/rakelib/02-test.rake +3 -18
  44. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +17 -2
  45. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +33 -0
  46. metadata +8 -40
  47. data/lib/active_record/connection_adapters/as400_adapter.rb +0 -2
  48. data/lib/active_record/connection_adapters/db2_adapter.rb +0 -1
  49. data/lib/active_record/connection_adapters/derby_adapter.rb +0 -1
  50. data/lib/active_record/connection_adapters/informix_adapter.rb +0 -1
  51. data/lib/arel/visitors/db2.rb +0 -137
  52. data/lib/arel/visitors/derby.rb +0 -112
  53. data/lib/arel/visitors/firebird.rb +0 -79
  54. data/lib/arjdbc/db2/adapter.rb +0 -808
  55. data/lib/arjdbc/db2/as400.rb +0 -142
  56. data/lib/arjdbc/db2/column.rb +0 -131
  57. data/lib/arjdbc/db2/connection_methods.rb +0 -48
  58. data/lib/arjdbc/db2.rb +0 -4
  59. data/lib/arjdbc/derby/active_record_patch.rb +0 -13
  60. data/lib/arjdbc/derby/adapter.rb +0 -521
  61. data/lib/arjdbc/derby/connection_methods.rb +0 -20
  62. data/lib/arjdbc/derby/schema_creation.rb +0 -15
  63. data/lib/arjdbc/derby.rb +0 -3
  64. data/lib/arjdbc/firebird/adapter.rb +0 -413
  65. data/lib/arjdbc/firebird/connection_methods.rb +0 -23
  66. data/lib/arjdbc/firebird.rb +0 -4
  67. data/lib/arjdbc/informix/adapter.rb +0 -139
  68. data/lib/arjdbc/informix/connection_methods.rb +0 -9
  69. data/lib/arjdbc/sybase/adapter.rb +0 -47
  70. data/lib/arjdbc/sybase.rb +0 -2
  71. data/lib/arjdbc/tasks/db2_database_tasks.rb +0 -104
  72. data/lib/arjdbc/tasks/derby_database_tasks.rb +0 -95
  73. data/src/java/arjdbc/derby/DerbyModule.java +0 -178
  74. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +0 -152
  75. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +0 -174
  76. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59345f12074c8042ddc27f2234fda3ed1e63a8b29610b45e42e6631621872a84
4
- data.tar.gz: aa1ec94c11f8776a6ac82f00be956105d254d158cd88709f762dd02e3aa424eb
3
+ metadata.gz: 46248cf1484387bba94e6cfd944c4d81b03103b9fd075554655e71f52cc37ef2
4
+ data.tar.gz: 4a9592dfab799bf3093bc2b393617e67db319272703a4f985c6609add3b451a5
5
5
  SHA512:
6
- metadata.gz: edaf34229e549b40849ff3ba02dd9cc00bde1d38d2dc4a5778ae4228597b0b4289e5314ba02fb7c201c6ea3b8be56f170bac91e7fd13e1cd4c82b1f49a4820c9
7
- data.tar.gz: 02f8789a6fb0e82ececd0050c751d8bc1d71efe57363cff5bb7ee78b880c1a331418920de618ff206a77892528c26b78be5a35526432c6f17188e06cd1cdc472
6
+ metadata.gz: 80e0e9e9d4934e8bb53c997dd61eb82eb77cf823177be6fa93599d459d6eeb7e8cc4591ae90b7cf794c3c21d0c4e37b4aff9528e201c611df529da6d4ac3c610
7
+ data.tar.gz: 5603dea7f3811d3163bc41e701487c6859885e86cc0e4b69a9b039f87def2d733b4bfb5f2a6febcd8536b1c7ef794e7bfe1683b748aab8660f8822d7fec4f825
@@ -0,0 +1,273 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test-rails-mysql:
21
+
22
+ name: Rails Tests (MySQL)
23
+ runs-on: ubuntu-latest
24
+ strategy:
25
+ fail-fast: false
26
+ matrix:
27
+ ruby-version: ['jruby-head']
28
+ db: ['mysql2']
29
+ test_targets: ["rails:test_mysql2"]
30
+ ar_version: ["7-0-stable"]
31
+ prepared_statements: ['false', 'true']
32
+ driver: ['MySQL']
33
+
34
+ services:
35
+ mysql:
36
+ image: mysql:5.7
37
+ ports:
38
+ - 3306
39
+
40
+ env:
41
+ DB: ${{ matrix.db }}
42
+ AR_VERSION: ${{ matrix.ar_version }}
43
+ PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
44
+ DRIVER: ${{ matrix.driver }}
45
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
46
+
47
+ steps:
48
+ - uses: actions/checkout@v3
49
+ - name: Set up Ruby
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: ${{ matrix.ruby-version }}
53
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
54
+ - name: Setup database
55
+ run: |
56
+ sudo service mysql start
57
+ mysql --version || true # to see if we're using MySQL or MariaDB
58
+ mysql -u root -proot -e "CREATE USER rails@localhost;"
59
+ mysql -u root -proot -e "grant all privileges on activerecord_unittest.* to rails@localhost;"
60
+ mysql -u root -proot -e "grant all privileges on activerecord_unittest2.* to rails@localhost;"
61
+ mysql -u root -proot -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;"
62
+ mysql -u root -proot -e "CREATE DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8mb4;"
63
+ mysql -u root -proot -e "CREATE DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8mb4;"
64
+ - name: Build
65
+ run: |
66
+ echo "JAVA_OPTS=$JAVA_OPTS"
67
+ rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
68
+ - name: Run tests
69
+ run: |
70
+ bundle exec rake ${{ matrix.test_targets }}
71
+
72
+ test-rails-pgsql:
73
+
74
+ name: Rails Tests (Postgres)
75
+ runs-on: ubuntu-latest
76
+ strategy:
77
+ fail-fast: false
78
+ matrix:
79
+ ruby-version: [ 'jruby-head' ]
80
+ db: [ 'postgresql' ]
81
+ test_targets: [ "rails:test_postgresql" ]
82
+ ar_version: ["7-0-stable"]
83
+ prepared_statements: [ 'false', 'true' ]
84
+
85
+ services:
86
+ postgres:
87
+ image: postgres:10
88
+ env:
89
+ POSTGRES_PASSWORD: postgres
90
+ POSTGRES_HOST_AUTH_METHOD: trust
91
+ ports:
92
+ - 5432:5432
93
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
94
+
95
+ env:
96
+ DB: ${{ matrix.db }}
97
+ AR_VERSION: ${{ matrix.ar_version }}
98
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
99
+ PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
100
+ PGHOST: localhost
101
+ PGPORT: 5432
102
+ PGUSER: postgres
103
+
104
+ steps:
105
+ - uses: actions/checkout@v3
106
+ - name: Set up Ruby
107
+ uses: ruby/setup-ruby@v1
108
+ with:
109
+ ruby-version: ${{ matrix.ruby-version }}
110
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
111
+ - name: Setup database
112
+ run: |
113
+ psql -c "create database activerecord_unittest;" -U postgres
114
+ psql -c "create database activerecord_unittest2;" -U postgres
115
+ - name: Build
116
+ run: |
117
+ rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
118
+ - name: Run tests
119
+ run: |
120
+ bundle exec rake ${{ matrix.test_targets }}
121
+
122
+ test-rails-sqlite:
123
+
124
+ name: Rails Tests (SQLite)
125
+ runs-on: ubuntu-latest
126
+ strategy:
127
+ fail-fast: false
128
+ matrix:
129
+ ruby-version: ['jruby-head']
130
+ db: ['sqlite3']
131
+ test_targets: ["rails:test_sqlite3"]
132
+ ar_version: ["7-0-stable"]
133
+
134
+ env:
135
+ DB: ${{ matrix.db }}
136
+ AR_VERSION: ${{ matrix.ar_version }}
137
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
138
+
139
+ steps:
140
+ - uses: actions/checkout@v3
141
+ - name: Set up Ruby
142
+ uses: ruby/setup-ruby@v1
143
+ with:
144
+ ruby-version: ${{ matrix.ruby-version }}
145
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
146
+ - name: Build
147
+ run: |
148
+ echo "JAVA_OPTS=$JAVA_OPTS"
149
+ rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
150
+ - name: Run tests
151
+ run: |
152
+ bundle exec rake ${{ matrix.test_targets }}
153
+
154
+ test-arjdbc-mysql:
155
+
156
+ name: ARJDBC Tests (MySQL)
157
+ runs-on: ubuntu-latest
158
+ strategy:
159
+ fail-fast: false
160
+ matrix:
161
+ ruby-version: ['jruby-head']
162
+ db: ['mysql2']
163
+ test_targets: ["db:mysql test_mysql2"]
164
+ prepared_statements: ['false', 'true']
165
+ driver: ['MySQL']
166
+
167
+ services:
168
+ mysql:
169
+ image: mysql:5.7
170
+ ports:
171
+ - 3306
172
+
173
+ env:
174
+ DB: ${{ matrix.db }}
175
+ DRIVER: ${{ matrix.driver }}
176
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
177
+ MY_USER: root
178
+ MY_PASSWORD: root
179
+ PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
180
+
181
+ steps:
182
+ - uses: actions/checkout@v3
183
+ - name: Set up Ruby
184
+ uses: ruby/setup-ruby@v1
185
+ with:
186
+ ruby-version: ${{ matrix.ruby-version }}
187
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
188
+ - name: Setup database
189
+ run: |
190
+ sudo service mysql start
191
+ mysql --version || true # to see if we're using MySQL or MariaDB
192
+ - name: Build
193
+ run: |
194
+ rake jar
195
+ - name: Run tests
196
+ run: |
197
+ bundle exec rake ${{ matrix.test_targets }}
198
+
199
+ test-arjdbc-pgsql:
200
+
201
+ name: ARJDBC Tests (Postgres)
202
+ runs-on: ubuntu-latest
203
+ strategy:
204
+ fail-fast: false
205
+ matrix:
206
+ ruby-version: ['jruby-head']
207
+ db: ['postgresql']
208
+ test_targets: ["db:postgresql test_postgresql"]
209
+ prepared_statements: ['false', 'true']
210
+ insert_returning: ['false', 'true']
211
+
212
+ services:
213
+ postgres:
214
+ image: postgres:10
215
+ env:
216
+ POSTGRES_PASSWORD: postgres
217
+ POSTGRES_HOST_AUTH_METHOD: trust
218
+ ports:
219
+ - 5432:5432
220
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
221
+
222
+ env:
223
+ DB: ${{ matrix.db }}
224
+ DRIVER: ${{ matrix.driver }}
225
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
226
+ PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
227
+ INSERT_RETURNING: ${{ matrix.insert_returning }}
228
+ PGHOST: localhost
229
+ PGPORT: 5432
230
+ PGUSER: postgres
231
+
232
+ steps:
233
+ - uses: actions/checkout@v3
234
+ - name: Set up Ruby
235
+ uses: ruby/setup-ruby@v1
236
+ with:
237
+ ruby-version: ${{ matrix.ruby-version }}
238
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
239
+ - name: Build
240
+ run: |
241
+ rake jar
242
+ - name: Run tests
243
+ run: |
244
+ bundle exec rake ${{ matrix.test_targets }}
245
+
246
+ test-arjdbc-sqlite:
247
+
248
+ name: ARJDBC Tests (SQLite)
249
+ runs-on: ubuntu-latest
250
+ strategy:
251
+ fail-fast: false
252
+ matrix:
253
+ ruby-version: ['jruby-head']
254
+ db: ['sqlite3']
255
+ test_targets: ['test_sqlite3']
256
+
257
+ env:
258
+ DB: ${{ matrix.db }}
259
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
260
+
261
+ steps:
262
+ - uses: actions/checkout@v3
263
+ - name: Set up Ruby
264
+ uses: ruby/setup-ruby@v1
265
+ with:
266
+ ruby-version: ${{ matrix.ruby-version }}
267
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
268
+ - name: Build
269
+ run: |
270
+ rake jar
271
+ - name: Run tests
272
+ run: |
273
+ bundle exec rake ${{ matrix.test_targets }}
data/.gitignore CHANGED
@@ -36,3 +36,4 @@ lib/arjdbc/jdbc/adapter_java.jar
36
36
  tags
37
37
  pik.sh
38
38
  .ruby-version
39
+ .rubocop.yml
data/.travis.yml CHANGED
@@ -9,14 +9,13 @@ before_install:
9
9
  - rvm @default,@global do gem uninstall bundler -a -x -I || true
10
10
  - gem install bundler -v "~>1.17.3"
11
11
  install:
12
- - bundle config set --local without 'development'
13
- - bundle install
12
+ - bundle install --retry 3 --without development
14
13
  # to fix this issue: https://travis-ci.community/t/mariadb-10-1-fails-to-install-on-xenial/3151/3
15
14
  - mysql -u root -e 'CREATE USER IF NOT EXISTS travis@localhost; GRANT ALL ON *.* TO travis@localhost;' || true
16
15
 
17
16
  language: ruby
18
17
  rvm:
19
- - jruby-9.2.19.0
18
+ - jruby-9.2.14.0
20
19
  jdk:
21
20
  - openjdk8
22
21
 
@@ -49,7 +48,7 @@ before_script:
49
48
 
50
49
  env:
51
50
  global:
52
- - AR_VERSION="6-1-stable"
51
+ - AR_VERSION="master"
53
52
  matrix:
54
53
  allow_failures:
55
54
  - rvm: jruby-head
data/Gemfile CHANGED
@@ -44,14 +44,14 @@ elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
44
44
  end
45
45
  end
46
46
  else
47
- gemspec name: 'activerecord-jdbc-adapter' # Use versiom from .gemspec
47
+ gemspec name: 'activerecord-jdbc-alt-adapter' # Use versiom from .gemspec
48
48
  end
49
49
 
50
- gem 'rake', '>= 11.1', require: nil
50
+ gem 'rake', require: nil
51
51
 
52
52
  group :test do
53
- gem 'test-unit', '~> 2.5.4', require: nil
54
- gem 'test-unit-context', '>= 0.4.0', require: nil
53
+ gem 'test-unit', require: nil
54
+ gem 'test-unit-context', require: nil
55
55
  gem 'mocha', '~> 1.2', require: false # Rails has '~> 0.14'
56
56
 
57
57
  gem 'bcrypt', '~> 3.1.11', require: false
@@ -61,8 +61,8 @@ end
61
61
 
62
62
  group :rails do
63
63
  group :test do
64
- gem 'minitest', '~> 5.12.2', require: nil
65
- gem 'minitest-excludes', '~> 2.0.1', require: nil
64
+ gem 'minitest', require: nil
65
+ gem 'minitest-excludes', require: nil
66
66
  gem 'minitest-rg', require: nil
67
67
 
68
68
  gem 'benchmark-ips', require: nil
@@ -74,6 +74,8 @@ group :rails do
74
74
  gem 'erubis', require: nil # "~> 2.7.0"
75
75
  # NOTE: due rails/activerecord/test/cases/connection_management_test.rb
76
76
  gem 'rack', require: nil
77
+
78
+ gem 'zeitwerk'
77
79
  end
78
80
 
79
81
  group :development do
data/README.md CHANGED
@@ -15,6 +15,7 @@ stable of this adapter and Rails
15
15
  | 52.6.0 | 5.2.4 | 9.1.x |
16
16
  | 60.1.0 | 6.0.3 | 9.2.9 |
17
17
  | 61.0.0 | 6.1.3 | 9.2.16 |
18
+ | 70.0.0 | 7.0.4 | 9.4.1.0 |
18
19
 
19
20
  This adapter passes most of the Rails tests (ActiveRecord tests) with the
20
21
  exception of some test that are not compatible with the SQL Server. To run
@@ -29,7 +30,7 @@ Add the following to your `Gemfile`:
29
30
  ```ruby
30
31
  platforms :jruby do
31
32
  # Use jdbc as the database for Active Record
32
- gem 'activerecord-jdbc-alt-adapter', '~> 61.0.0'
33
+ gem 'activerecord-jdbc-alt-adapter', '~> 60.0.0.rc1'
33
34
  gem 'jdbc-mssql', '~> 0.9.0'
34
35
  end
35
36
  ```
data/Rakefile CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  require 'rake/clean'
28
28
 
29
- CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
29
+ CLEAN.include 'test.db.*', '*test.sqlite3', 'test/reports'
30
30
  CLEAN.include 'lib/**/*.jar', 'MANIFEST.MF', '*.log', 'target/*'
31
31
 
32
32
  task :default => :jar # RubyGems extention will do a bare `rake' e.g. :
@@ -41,12 +41,12 @@ Gem::Specification.new do |gem|
41
41
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
42
42
  gem.test_files = gem.files.grep(%r{^test/})
43
43
 
44
- gem.add_dependency 'activerecord', '~> 6.1.0'
44
+ gem.add_dependency 'activerecord', '~> 7.0'
45
45
 
46
46
  #gem.add_development_dependency 'test-unit', '2.5.4'
47
47
  #gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
48
48
  #gem.add_development_dependency 'mocha', '~> 0.13.1'
49
49
 
50
- gem.rdoc_options = ["--main", "README.md", "-SHN", "-f", "darkfish"]
50
+ gem.rdoc_options = ["--main", "README.md"]
51
51
  end
52
52
 
@@ -43,12 +43,12 @@ Gem::Specification.new do |gem|
43
43
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
44
44
  gem.test_files = gem.files.grep(%r{^test/})
45
45
 
46
- gem.add_dependency 'activerecord', '~> 6.1.0'
46
+ gem.add_dependency 'activerecord', '~> 7.0.0'
47
47
 
48
48
  #gem.add_development_dependency 'test-unit', '2.5.4'
49
49
  #gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
50
50
  #gem.add_development_dependency 'mocha', '~> 0.13.1'
51
51
 
52
- gem.rdoc_options = ["--main", "README.md", "-HN", "-f", "darkfish"]
52
+ gem.rdoc_options = ["--main", "README.md"]
53
53
  end
54
54
 
@@ -4,44 +4,16 @@ module Arel
4
4
 
5
5
  protected
6
6
 
7
- if ToSql.instance_method('visit').arity == 1
8
- def do_visit(x, a); visit(x); end # a = nil
9
- else # > AREL 4.0
10
- def do_visit(x, a); visit(x, a); end
11
- end
7
+ def do_visit(x, a); visit(x, a); end
12
8
 
13
- if ToSql.instance_method('visit_Arel_Nodes_SelectCore').arity == 1
14
- def do_visit_select_core(x, a) # a = nil
15
- visit_Arel_Nodes_SelectCore(x)
16
- end
17
- else # > AREL 4.0
18
- def do_visit_select_core(x, a)
19
- visit_Arel_Nodes_SelectCore(x, a)
20
- end
9
+ def do_visit_select_core(x, a)
10
+ visit_Arel_Nodes_SelectCore(x, a)
21
11
  end
22
12
 
23
13
  private
24
14
 
25
- if ArJdbc::AR42
26
- if Arel::VERSION < '6.0.2'
27
- def limit_for(limit_or_node)
28
- if limit_or_node.respond_to?(:expr)
29
- expr = limit_or_node.expr
30
- # NOTE(uwe): Different behavior for Arel 6.0.0 and 6.0.2
31
- expr.respond_to?(:value) ? expr.value.to_i : expr.to_i
32
- else
33
- limit_or_node
34
- end
35
- end
36
- else
37
- def limit_for(limit_or_node)
38
- limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
39
- end
40
- end
41
- else
42
- def limit_for(limit_or_node)
43
- limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
44
- end
15
+ def limit_for(limit_or_node)
16
+ limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
45
17
  end
46
18
  module_function :limit_for
47
19
 
@@ -7,19 +7,7 @@ module Arel
7
7
  def visit_Arel_Nodes_SelectStatement(o, *)
8
8
  o.limit ||= Arel::Nodes::Limit.new(-1) if o.offset
9
9
  super
10
- end if ArJdbc::AR42
11
-
12
- def limit_offset sql, o
13
- offset = o.offset || 0
14
- offset = offset.expr unless (offset.nil? || offset == 0)
15
- if limit = o.limit
16
- "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
17
- elsif offset > 0
18
- "SELECT LIMIT #{offset} -1 #{sql[7..-1]}" # removes "SELECT "
19
- else
20
- sql
21
- end
22
- end unless ArJdbc::AR42
10
+ end
23
11
  end
24
12
  end
25
13
  end
@@ -6,27 +6,7 @@ module Arel
6
6
  def visit_Arel_Nodes_SelectStatement(o, *)
7
7
  o.limit ||= Arel::Nodes::Limit.new(0) if o.offset
8
8
  super
9
- end if ArJdbc::AR42
10
-
11
- def visit_Arel_Nodes_SelectStatement o, a = nil
12
- sql = limit_offset(o.cores.map { |x| do_visit_select_core x, a }.join, o)
13
- sql << " ORDER BY #{o.orders.map { |x| do_visit x, a }.join(', ')}" unless o.orders.empty?
14
- sql
15
- end unless ArJdbc::AR42
16
-
17
- private
18
-
19
- def limit_offset sql, o
20
- offset = o.offset || 0
21
- offset = offset.expr unless (offset.nil? || offset == 0)
22
- if limit = o.limit
23
- "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
24
- elsif offset > 0
25
- "SELECT LIMIT #{offset} 0 #{sql[7..-1]}" # removes "SELECT "
26
- else
27
- sql
28
- end
29
- end unless ArJdbc::AR42
9
+ end
30
10
  end
31
11
  end
32
12
  end
@@ -11,44 +11,6 @@ module Arel
11
11
 
12
12
  private
13
13
 
14
- def visit_Arel_Nodes_SelectStatement(*args) # [o] AR <= 4.0 [o, a] on 4.1
15
- o, a = args.first, args.last
16
-
17
- return _visit_Arel_Nodes_SelectStatement(*args) if ! o.limit && ! o.offset
18
-
19
- unless o.orders.empty?
20
- select_order_by = do_visit_columns o.orders, a, 'ORDER BY '
21
- end
22
-
23
- select_count = false; sql = ''
24
- o.cores.each do |x|
25
- x = x.dup
26
- core_order_by = select_order_by || determine_order_by(x, a)
27
- if select_count? x
28
- x.projections = [
29
- Arel::Nodes::SqlLiteral.new(core_order_by ? over_row_num(core_order_by) : '*')
30
- ]
31
- select_count = true
32
- else
33
- # NOTE: this should really be added here and we should built the
34
- # wrapping SQL but than #replace_limit_offset! assumes it does that
35
- # ... MS-SQL adapter code seems to be 'hacked' by a lot of people
36
- #x.projections << Arel::Nodes::SqlLiteral.new over_row_num(order_by)
37
- end
38
- sql << do_visit_select_core(x, a)
39
- end
40
-
41
- #sql = "SELECT _t.* FROM (#{sql}) as _t WHERE #{get_offset_limit_clause(o)}"
42
- select_order_by ||= "ORDER BY #{@connection.determine_order_clause(sql)}"
43
- replace_limit_offset!(sql, limit_for(o.limit), o.offset && o.offset.value.to_i, select_order_by)
44
-
45
- sql = "SELECT COUNT(*) AS count_id FROM (#{sql}) AS subquery" if select_count
46
-
47
- add_lock!(sql, :lock => o.lock && true)
48
-
49
- sql
50
- end unless ArJdbc::AR42
51
-
52
14
  # @private
53
15
  MAX_LIMIT_VALUE = 9_223_372_036_854_775_807
54
16
 
@@ -60,14 +22,6 @@ module Arel
60
22
  super
61
23
  end
62
24
 
63
- def visit_Arel_Nodes_Lock o, a = nil
64
- # MS-SQL doesn't support "SELECT...FOR UPDATE". Instead, it needs
65
- # WITH(ROWLOCK,UPDLOCK) specified after each table in the FROM clause.
66
- #
67
- # we return nothing here and add the appropriate stuff with #add_lock!
68
- #do_visit o.expr, a
69
- end unless ArJdbc::AR42
70
-
71
25
  def visit_Arel_Nodes_Top o, a = nil
72
26
  # `top` wouldn't really work here:
73
27
  # User.select("distinct first_name").limit(10)
@@ -76,29 +30,6 @@ module Arel
76
30
  a || ''
77
31
  end
78
32
 
79
- def visit_Arel_Nodes_Limit o, a = nil
80
- "TOP (#{do_visit o.expr, a})"
81
- end unless ArJdbc::AR42
82
-
83
- def visit_Arel_Nodes_Ordering o, a = nil
84
- expr = do_visit o.expr, a
85
- if o.respond_to?(:direction)
86
- "#{expr} #{o.ascending? ? 'ASC' : 'DESC'}"
87
- else
88
- expr
89
- end
90
- end unless ArJdbc::AR42
91
-
92
- def visit_Arel_Nodes_Bin o, a = nil
93
- expr = o.expr; sql = do_visit expr, a
94
- if expr.respond_to?(:val) && expr.val.is_a?(Numeric)
95
- sql
96
- else
97
- sql << " #{::ArJdbc::MSSQL.cs_equality_operator} "
98
- sql
99
- end
100
- end unless ArJdbc::AR42
101
-
102
33
  private
103
34
 
104
35
  def self.possibly_private_method_defined?(name)
@@ -140,25 +71,7 @@ module Arel
140
71
  visit(x, sql); sql << ', ' unless i == last
141
72
  end
142
73
  sql.value
143
- end if ArJdbc::AR42
144
-
145
- def do_visit_columns(colls, a, sql)
146
- non_simple_order = /\sASC|\sDESC|\sCASE|\sCOLLATE|[\.,\[\(]/i # MIN(width)
147
-
148
- last = colls.size - 1
149
- colls.each_with_index do |x, i|
150
- coll = do_visit(x, a)
151
-
152
- if coll !~ non_simple_order && coll.to_i == 0
153
- sql << @connection.quote_column_name(coll)
154
- else
155
- sql << coll
156
- end
157
-
158
- sql << ', ' unless i == last
159
- end
160
- sql
161
- end if Arel::VERSION < '4.0.0'
74
+ end
162
75
 
163
76
  def over_row_num order_by
164
77
  "ROW_NUMBER() OVER (#{order_by}) as _row_num"
@@ -174,20 +87,6 @@ module Arel
174
87
  end
175
88
  end
176
89
 
177
- def table_from_select_core core
178
- table_finder = lambda do |x|
179
- case x
180
- when Arel::Table
181
- x
182
- when Arel::Nodes::SqlLiteral
183
- Arel::Table.new(x, @engine)
184
- when Arel::Nodes::Join
185
- table_finder.call(x.left)
186
- end
187
- end
188
- table_finder.call(core.froms)
189
- end if ActiveRecord::VERSION::STRING < '3.2'
190
-
191
90
  def primary_key_from_table t
192
91
  return unless t
193
92
  return t.primary_key if t.primary_key
@@ -219,7 +118,7 @@ module Arel
219
118
  include ArJdbc::MSSQL::LimitHelpers::SqlServer2000ReplaceLimitOffset
220
119
  end
221
120
 
222
- load 'arel/visitors/sql_server/ng42.rb' if ArJdbc::AR42
121
+ load 'arel/visitors/sql_server/ng42.rb'
223
122
 
224
123
  end
225
124
  end