activerecord-advantage-adapter 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0b104f4e9d8fb204bc6249aa06448f5881292745123dd94c2def2eee9254dad
|
4
|
+
data.tar.gz: 3e64e4089e520711b10ca37cb3b3404834c2b939d65a50898e19d1735c4f3d50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f100c25e14250e25e93ecadfe20f1bbe2c5ee1e42d3980924771111cc7ac5a094a3ab2f2db057bbd2ac8630ca195e15a60892fbc8dd47eb90ef2f4c8c324204
|
7
|
+
data.tar.gz: 3ecae6463a95d48e9e1f9ef194fe8adde8333e39c74f9d90d405fd63acc64a59cbdcfb91b0fdea786ce1dca00f5dff93c142dbfaf8fef62a4465a8af65fae4bc
|
@@ -1,7 +1,7 @@
|
|
1
1
|
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
|
-
pkg_version = "0.1.
|
4
|
+
pkg_version = "0.1.4"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "activerecord-advantage-adapter"
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
23
|
# Changed to the github project, as this is the actively maintained source, now.
|
24
24
|
spec.metadata["source_code_uri"] = "https://github.com/t12nslookup/activerecord-advantage-adapter/"
|
25
|
-
spec.metadata["changelog_uri"] = "https://github.com/t12nslookup/activerecord-advantage-adapter/
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/t12nslookup/activerecord-advantage-adapter/CHANGELOG.md"
|
26
26
|
else
|
27
27
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
28
28
|
"public gem pushes."
|
@@ -78,6 +78,7 @@ module ActiveRecord
|
|
78
78
|
private
|
79
79
|
|
80
80
|
# Overridden to handle Advantage integer, varchar, binary, and timestamp types
|
81
|
+
# Rails 4 does not use this.
|
81
82
|
def simplified_type(field_type)
|
82
83
|
case field_type
|
83
84
|
when /logical/i
|
@@ -94,16 +95,6 @@ module ActiveRecord
|
|
94
95
|
super
|
95
96
|
end
|
96
97
|
end
|
97
|
-
|
98
|
-
# JAD Is this helpful?
|
99
|
-
def initialize_type_map(m = type_map)
|
100
|
-
m.alias_type %r(memo)i, "char"
|
101
|
-
m.alias_type %r(long binary)i, "binary"
|
102
|
-
m.alias_type %r(integer)i, "int"
|
103
|
-
m.alias_type %r(short)i, "int"
|
104
|
-
m.alias_type %r(autoinc)i, "int"
|
105
|
-
super
|
106
|
-
end
|
107
98
|
end
|
108
99
|
|
109
100
|
class AdvantageAdapter < AbstractAdapter
|
@@ -118,7 +109,7 @@ module ActiveRecord
|
|
118
109
|
end
|
119
110
|
|
120
111
|
def adapter_name #:nodoc:
|
121
|
-
|
112
|
+
'Advantage'
|
122
113
|
end
|
123
114
|
|
124
115
|
def supports_migrations? #:nodoc:
|
@@ -130,13 +121,13 @@ module ActiveRecord
|
|
130
121
|
end
|
131
122
|
|
132
123
|
def active? #:nodoc:
|
133
|
-
ADS.instance.api.ads_execute_immediate(@connection,
|
134
|
-
rescue
|
124
|
+
ADS.instance.api.ads_execute_immediate(@connection, 'SELECT 1 FROM SYSTEM.IOTA') == 1
|
125
|
+
rescue StandardError
|
135
126
|
false
|
136
127
|
end
|
137
128
|
|
138
129
|
def disconnect! #:nodoc:
|
139
|
-
|
130
|
+
_result = ADS.instance.api.ads_disconnect(@connection)
|
140
131
|
super
|
141
132
|
end
|
142
133
|
|
@@ -180,20 +171,21 @@ module ActiveRecord
|
|
180
171
|
|
181
172
|
# Applies quotations around column names in generated queries
|
182
173
|
def quote_column_name(name) #:nodoc:
|
183
|
-
%
|
174
|
+
%("#{name}")
|
184
175
|
end
|
185
176
|
|
186
177
|
def quoted_true #:nodoc:
|
187
|
-
|
178
|
+
'1'
|
188
179
|
end
|
189
180
|
|
190
181
|
def quoted_false #:nodoc:
|
191
|
-
|
182
|
+
'0'
|
192
183
|
end
|
193
184
|
|
194
185
|
# Translate the exception if possible
|
195
186
|
def translate_exception(exception, message) #:nodoc:
|
196
187
|
return super unless exception.respond_to?(:errno)
|
188
|
+
|
197
189
|
case exception.errno
|
198
190
|
when 2121
|
199
191
|
if exception.sql !~ /^SELECT/i
|
@@ -214,13 +206,13 @@ module ActiveRecord
|
|
214
206
|
# The database update function.
|
215
207
|
def update_sql(sql, name = nil) #:nodoc:
|
216
208
|
execute(sql, name)
|
217
|
-
|
209
|
+
@affected_rows
|
218
210
|
end
|
219
211
|
|
220
212
|
# The database delete function.
|
221
213
|
def delete_sql(sql, name = nil) #:nodoc:
|
222
214
|
execute(sql, name)
|
223
|
-
|
215
|
+
@affected_rows
|
224
216
|
end
|
225
217
|
|
226
218
|
# The database insert function.
|
@@ -228,37 +220,38 @@ module ActiveRecord
|
|
228
220
|
# by immediatly querying the @@identity property. If the @@identity property is 0, then passed id_value is used
|
229
221
|
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc:
|
230
222
|
execute(sql, name)
|
231
|
-
|
223
|
+
_identity = last_inserted_id(nil)
|
232
224
|
retval = id_value if retval == 0
|
233
|
-
|
225
|
+
retval
|
234
226
|
end
|
235
227
|
|
236
228
|
# The Database insert function as part of the rails changes
|
237
|
-
def exec_insert(sql,
|
238
|
-
log(sql,
|
229
|
+
def exec_insert(sql, _name = nil, binds = [], _pk = nil, _sequence_name = nil) #:nodoc:
|
230
|
+
log(sql, 'insert', binds) { exec_query(sql, binds) }
|
239
231
|
end
|
240
232
|
|
241
233
|
# The Database update function as part of the rails changes
|
242
|
-
def exec_update(sql,
|
243
|
-
log(sql,
|
234
|
+
def exec_update(sql, _name = nil, binds = []) #:nodoc:
|
235
|
+
log(sql, 'update', binds) { exec_query(sql, binds) }
|
244
236
|
end
|
245
237
|
|
246
238
|
# The Database delete function as part of the rails changes
|
247
|
-
def exec_delete(sql,
|
248
|
-
log(sql,
|
239
|
+
def exec_delete(sql, _name = nil, binds = []) #:nodoc:
|
240
|
+
log(sql, 'delete', binds) { exec_query(sql, binds) }
|
249
241
|
end
|
250
242
|
|
251
|
-
def exec_query(sql, name = "SQL",
|
243
|
+
def exec_query(sql, name = "SQL", _binds = [])
|
252
244
|
cols, record = execute(sql, name)
|
253
245
|
ActiveRecord::Result.new(cols, record)
|
254
246
|
end
|
255
247
|
|
256
248
|
# Retrieve the last AutoInc ID
|
257
|
-
def last_inserted_id(
|
258
|
-
rs = ADS.instance.api.ads_execute_direct(@connection,
|
249
|
+
def last_inserted_id(_result) #:nodoc:
|
250
|
+
rs = ADS.instance.api.ads_execute_direct(@connection, 'SELECT LASTAUTOINC( CONNECTION ) FROM SYSTEM.IOTA')
|
259
251
|
raise ActiveRecord::StatementInvalid.new("#{ADS.instance.api.ads_error(@connection)}:#{sql}") if rs.nil?
|
252
|
+
|
260
253
|
ADS.instance.api.ads_fetch_next(rs)
|
261
|
-
|
254
|
+
_retval, identity = ADS.instance.api.ads_get_column(rs, 0)
|
262
255
|
ADS.instance.api.ads_free_stmt(rs)
|
263
256
|
identity
|
264
257
|
end
|
@@ -292,10 +285,10 @@ module ActiveRecord
|
|
292
285
|
|
293
286
|
# Advantage does not support sizing of integers based on the sytax INTEGER(size).
|
294
287
|
def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
|
295
|
-
if
|
288
|
+
if native_database_types[type]
|
296
289
|
if type == :integer
|
297
|
-
|
298
|
-
elsif type == :string
|
290
|
+
'integer'
|
291
|
+
elsif type == :string && !limit.nil?
|
299
292
|
"varchar (#{limit})"
|
300
293
|
else
|
301
294
|
super(type, limit, precision, scale)
|
@@ -306,35 +299,35 @@ module ActiveRecord
|
|
306
299
|
end
|
307
300
|
|
308
301
|
# Retrieve a list of Tables
|
309
|
-
def data_source_sql(name = nil,
|
302
|
+
def data_source_sql(name = nil, _type = nil) #:nodoc:
|
310
303
|
"SELECT table_name from (EXECUTE PROCEDURE sp_GetTables( NULL, NULL, '#{name}', 'TABLE' )) spgc where table_cat <> 'system';"
|
311
304
|
end
|
312
305
|
|
313
306
|
# Retrieve a list of Tables
|
314
307
|
def tables(name = nil) #:nodoc:
|
315
308
|
sql = "EXECUTE PROCEDURE sp_GetTables( NULL, NULL, NULL, 'TABLE' );"
|
316
|
-
select(sql, name).map { |row| strip_or_self(row[
|
309
|
+
select(sql, name).map { |row| strip_or_self(row['TABLE_NAME']) }
|
317
310
|
end
|
318
311
|
|
319
312
|
# Return a list of columns
|
320
|
-
def columns(table_name,
|
313
|
+
def columns(table_name, _name = nil) #:nodoc:
|
321
314
|
table_structure(table_name).map do |field|
|
322
315
|
if Rails::VERSION::MAJOR > 4
|
323
|
-
AdvantageColumn.new(strip_or_self(field[
|
324
|
-
field[
|
325
|
-
|
326
|
-
field[
|
316
|
+
AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']),
|
317
|
+
field['COLUMN_DEF'],
|
318
|
+
fetch_type_metadata(strip_or_self(field['TYPE_NAME'])),
|
319
|
+
field['NULLABLE'])
|
327
320
|
elsif Rails::VERSION::MAJOR == 4
|
328
|
-
AdvantageColumn.new(strip_or_self(field[
|
329
|
-
field[
|
330
|
-
lookup_cast_type(strip_or_self(field[
|
331
|
-
strip_or_self(field[
|
332
|
-
field[
|
321
|
+
AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']),
|
322
|
+
field['COLUMN_DEF'],
|
323
|
+
lookup_cast_type(strip_or_self(field['TYPE_NAME'])),
|
324
|
+
strip_or_self(field['TYPE_NAME']),
|
325
|
+
field['NULLABLE'])
|
333
326
|
else
|
334
|
-
AdvantageColumn.new(strip_or_self(field[
|
335
|
-
field[
|
336
|
-
strip_or_self(field[
|
337
|
-
field[
|
327
|
+
AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']),
|
328
|
+
field['COLUMN_DEF'],
|
329
|
+
strip_or_self(field['TYPE_NAME']),
|
330
|
+
field['NULLABLE'])
|
338
331
|
end
|
339
332
|
end
|
340
333
|
end
|
@@ -342,13 +335,17 @@ module ActiveRecord
|
|
342
335
|
# Return a list of indexes
|
343
336
|
# EJS - Is there a way to get info without DD?
|
344
337
|
def indexes(table_name, name = nil) #:nodoc:
|
345
|
-
sql = "SELECT
|
338
|
+
sql = "SELECT INDEX_NAME, COLUMN_NAME, NON_UNIQUE FROM (EXECUTE PROCEDURE sp_GetIndexInfo( NULL, NULL, '#{table_name}', NULL, FALSE)) as gii"
|
346
339
|
select(sql, name).map do |row|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
340
|
+
next if row['INDEX_NAME'].blank?
|
341
|
+
|
342
|
+
IndexDefinition.new(
|
343
|
+
table_name,
|
344
|
+
row['INDEX_NAME'],
|
345
|
+
row['NON_UNIQUE'].zero?,
|
346
|
+
row['COLUMN_NAME'].split(',').map(&:strip)
|
347
|
+
)
|
348
|
+
end.compact
|
352
349
|
end
|
353
350
|
|
354
351
|
# Return the primary key
|
@@ -458,6 +455,9 @@ SQL
|
|
458
455
|
sql = "SELECT COLUMN_NAME, IIF(COLUMN_DEF = 'NULL', null, COLUMN_DEF) as COLUMN_DEF, TYPE_NAME, NULLABLE from (EXECUTE PROCEDURE sp_GetColumns( NULL, NULL, '#{table_name}', NULL )) spgc where table_cat <> 'system';"
|
459
456
|
structure = exec_query(sql, :skip_logging)
|
460
457
|
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure == false
|
458
|
+
|
459
|
+
# Add in a "ROWID" column to the structure?
|
460
|
+
structure.rows.unshift(['ROWID', nil, 'CHAR', 1]) if structure.rows.any?
|
461
461
|
structure
|
462
462
|
end
|
463
463
|
|
@@ -468,6 +468,17 @@ SQL
|
|
468
468
|
|
469
469
|
private
|
470
470
|
|
471
|
+
# Used in the lookup_cast_type procedure
|
472
|
+
def initialize_type_map(m = type_map)
|
473
|
+
super
|
474
|
+
m.alias_type %r(memo)i, "char"
|
475
|
+
m.alias_type %r(long binary)i, "binary"
|
476
|
+
m.alias_type %r(integer)i, "int"
|
477
|
+
m.alias_type %r(short)i, "int"
|
478
|
+
m.alias_type %r(autoinc)i, "int"
|
479
|
+
m.alias_type %r(logical)i, "boolean"
|
480
|
+
end
|
481
|
+
|
471
482
|
# Connect
|
472
483
|
def connect! #:nodoc:
|
473
484
|
result = ADS.instance.api.ads_connect(@connection, @connection_string)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-advantage-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar Sherman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -94,7 +94,7 @@ metadata:
|
|
94
94
|
allowed_push_host: https://rubygems.org
|
95
95
|
homepage_uri: http://devzone.advantagedatabase.com
|
96
96
|
source_code_uri: https://github.com/t12nslookup/activerecord-advantage-adapter/
|
97
|
-
changelog_uri: https://github.com/t12nslookup/activerecord-advantage-adapter/
|
97
|
+
changelog_uri: https://github.com/t12nslookup/activerecord-advantage-adapter/CHANGELOG.md
|
98
98
|
post_install_message:
|
99
99
|
rdoc_options: []
|
100
100
|
require_paths:
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.1.
|
113
|
+
rubygems_version: 3.1.4
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: ActiveRecord driver for Advantage
|