ibm_db 2.5.18-x86-mingw32 → 2.5.25-x86-mingw32

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.
@@ -1,11 +1,12 @@
1
1
  # +----------------------------------------------------------------------+
2
2
  # | Licensed Materials - Property of IBM |
3
3
  # | |
4
- # | (C) Copyright IBM Corporation 2006, 2007, 2008, 2009, 2010 |
4
+ # | (C) Copyright IBM Corporation 2006- 2015 |
5
5
  # +----------------------------------------------------------------------+
6
6
  # | Authors: Antonio Cangiano <cangiano@ca.ibm.com> |
7
7
  # | : Mario Ds Briggs <mario.briggs@in.ibm.com> |
8
8
  # | : Praveen Devarao <praveendrl@in.ibm.com> |
9
+ # | : Arvind Gupta <arvindgu@in.ibm.com> |
9
10
  # +----------------------------------------------------------------------+
10
11
 
11
12
  require 'active_record/connection_adapters/abstract_adapter'
@@ -725,17 +726,24 @@ module ActiveRecord
725
726
  def self.visitor_for(pool)
726
727
  Arel::Visitors::IBM_DB.new(pool)
727
728
  end
728
-
729
- def to_sql(arel, binds = [])
730
- if arel.respond_to?(:ast)
731
- visitor.accept(arel.ast) do
732
- quote(*binds.shift.reverse)
733
- end
734
- else
735
- arel
736
- end
729
+
730
+ #Check Arel version
731
+ begin
732
+ @arelVersion = Arel::VERSION.to_i
733
+ rescue
734
+ @arelVersion = 0
737
735
  end
738
-
736
+ if(@arelVersion < 6)
737
+ def to_sql(arel, binds = [])
738
+ if arel.respond_to?(:ast)
739
+ visitor.accept(arel.ast) do
740
+ quote(*binds.shift.reverse)
741
+ end
742
+ else
743
+ arel
744
+ end
745
+ end
746
+ end
739
747
  # This adapter supports migrations.
740
748
  # Current limitations:
741
749
  # +rename_column+ is not currently supported by the IBM data servers
@@ -1118,7 +1126,11 @@ module ActiveRecord
1118
1126
  end
1119
1127
 
1120
1128
  def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [] )
1121
- sql, binds = [to_sql(arel),binds]
1129
+ if(@arelVersion < 6 )
1130
+ sql, binds = [to_sql(arel),binds]
1131
+ else
1132
+ sql, binds = sql_for_insert(to_sql(arel, binds), pk, id_value, sequence_name, binds) #[to_sql(arel),binds]
1133
+ end
1122
1134
 
1123
1135
  #unless IBM_DBAdapter.respond_to?(:exec_insert)
1124
1136
  if binds.nil? || binds.empty?
@@ -1278,7 +1290,11 @@ module ActiveRecord
1278
1290
  alias_method :prepared_delete, :prepared_update
1279
1291
 
1280
1292
  def update(arel, name = nil, binds = [])
1281
- sql = to_sql(arel)
1293
+ if(@arelVersion < 6 )
1294
+ sql = to_sql(arel)
1295
+ else
1296
+ sql = to_sql(arel,binds)
1297
+ end
1282
1298
 
1283
1299
  # Make sure the WHERE clause handles NULL's correctly
1284
1300
  sqlarray = sql.split(/\s*WHERE\s*/)
@@ -1335,6 +1351,13 @@ module ActiveRecord
1335
1351
  IBM_DB.autocommit @connection, IBM_DB::SQL_AUTOCOMMIT_ON
1336
1352
  end
1337
1353
 
1354
+ def get_limit_offset_clauses(limit,offset)
1355
+ if limit && limit == 0
1356
+ clauses = @servertype.get_limit_offset_clauses(limit,0)
1357
+ else
1358
+ clauses = @servertype.get_limit_offset_clauses(limit, offset)
1359
+ end
1360
+ end
1338
1361
 
1339
1362
  # Modifies a sql statement in order to implement a LIMIT and an OFFSET.
1340
1363
  # A LIMIT defines the number of rows that should be fetched, while
@@ -1459,7 +1482,7 @@ module ActiveRecord
1459
1482
  end
1460
1483
  elsif column && column.type.to_sym == :text
1461
1484
  unless caller[0] =~ /add_column_options/i
1462
- "'@@@IBMTEXT@@@'"
1485
+ "'<ibm>@@@IBMTEXT@@@</ibm>'"
1463
1486
  else
1464
1487
  @servertype.set_text_default(quote_string(value))
1465
1488
  end
@@ -1879,7 +1902,8 @@ module ActiveRecord
1879
1902
  if !(column_name =~ /db2_generated_rowid_for_lobs/i)
1880
1903
  # Pushes into the array the *IBM_DBColumn* object, created by passing to the initializer
1881
1904
  # +column_name+, +default_value+, +column_type+ and +column_nullable+.
1882
- columns << IBM_DBColumn.new(column_name, column_default_value, column_type, column_nullable)
1905
+ cast_type = lookup_cast_type(column_type)
1906
+ columns << IBM_DBColumn.new(column_name, column_default_value, cast_type, column_type, column_nullable)
1883
1907
  end
1884
1908
  end
1885
1909
  rescue StandardError => fetch_error # Handle driver fetch errors
@@ -2009,6 +2033,47 @@ module ActiveRecord
2009
2033
  def remove_index(table_name, options = {})
2010
2034
  execute("DROP INDEX #{index_name(table_name, options)}")
2011
2035
  end
2036
+
2037
+ protected
2038
+ def initialize_type_map(m) # :nodoc:
2039
+ register_class_with_limit m, %r(boolean)i, Type::Boolean
2040
+ register_class_with_limit m, %r(char)i, Type::String
2041
+ register_class_with_limit m, %r(binary)i, Type::Binary
2042
+ register_class_with_limit m, %r(text)i, Type::Text
2043
+ register_class_with_limit m, %r(date)i, Type::Date
2044
+ register_class_with_limit m, %r(time)i, Type::Time
2045
+ register_class_with_limit m, %r(datetime)i, Type::DateTime
2046
+ register_class_with_limit m, %r(float)i, Type::Float
2047
+ register_class_with_limit m, %r(int)i, Type::Integer
2048
+
2049
+ m.alias_type %r(blob)i, 'binary'
2050
+ m.alias_type %r(clob)i, 'text'
2051
+ m.alias_type %r(timestamp)i, 'datetime'
2052
+ m.alias_type %r(numeric)i, 'decimal'
2053
+ m.alias_type %r(number)i, 'decimal'
2054
+ m.alias_type %r(double)i, 'float'
2055
+
2056
+ m.register_type(%r(decimal)i) do |sql_type|
2057
+ scale = extract_scale(sql_type)
2058
+ precision = extract_precision(sql_type)
2059
+
2060
+ if scale == 0
2061
+ # FIXME: Remove this class as well
2062
+ Type::DecimalWithoutScale.new(precision: precision)
2063
+ else
2064
+ Type::Decimal.new(precision: precision, scale: scale)
2065
+ end
2066
+ end
2067
+
2068
+ m.alias_type %r(xml)i, 'text'
2069
+ m.alias_type %r(for bit data)i, 'binary'
2070
+ m.alias_type %r(smallint)i, 'boolean'
2071
+ m.alias_type %r(serial)i, 'int'
2072
+ m.alias_type %r(decfloat)i, 'decimal'
2073
+ m.alias_type %r(real)i, 'decimal'
2074
+ m.alias_type %r(graphic)i, 'binary'
2075
+ m.alias_type %r(rowid)i, 'int'
2076
+ end
2012
2077
  end # class IBM_DBAdapter
2013
2078
 
2014
2079
  # This class contains common code across DB's (DB2 LUW, zOS, i5 and IDS)
@@ -2145,6 +2210,9 @@ To remove the column, the table must be dropped and recreated without the #{colu
2145
2210
  def query_offset_limit(sql, offset, limit)
2146
2211
  end
2147
2212
 
2213
+ def get_limit_offset_clauses(limit, offset)
2214
+ end
2215
+
2148
2216
  def query_offset_limit!(sql, offset, limit, options)
2149
2217
  end
2150
2218
 
@@ -2507,6 +2575,30 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2507
2575
  end
2508
2576
  end
2509
2577
  =end
2578
+ def get_limit_offset_clauses(limit, offset)
2579
+ retHash = {"endSegment"=> "", "startSegment" => ""}
2580
+ if(offset.nil? && limit.nil?)
2581
+ return retHash
2582
+ end
2583
+
2584
+ if (offset.nil?)
2585
+ retHash["endSegment"] = " FETCH FIRST #{limit} ROWS ONLY"
2586
+ return retHash
2587
+ end
2588
+
2589
+ if(limit.nil?)
2590
+ retHash["startSegment"] = "SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM ( SELECT "
2591
+ retHash["endSegment"] = " ) AS I) AS O WHERE sys_row_num > #{offset}"
2592
+ return retHash
2593
+ end
2594
+
2595
+ # Defines what will be the last record
2596
+ last_record = offset.to_i + limit.to_i
2597
+ retHash["startSegment"] = "SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM ( SELECT "
2598
+ retHash["endSegment"] = " ) AS I) AS O WHERE sys_row_num BETWEEN #{offset+1} AND #{last_record}"
2599
+ return retHash
2600
+ end
2601
+
2510
2602
  def query_offset_limit(sql, offset, limit)
2511
2603
  if(offset.nil? && limit.nil?)
2512
2604
  return sql
@@ -2727,6 +2819,14 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2727
2819
  class IBM_DB2_ZOS_8 < IBM_DB2_ZOS
2728
2820
  include HostedDataServer
2729
2821
 
2822
+ def get_limit_offset_clauses(limit, offset)
2823
+ retHash = {"startSegment" => "", "endSegment" => ""}
2824
+ if (!limit.nil?)
2825
+ retHash["endSegment"] = " FETCH FIRST #{limit} ROWS ONLY"
2826
+ end
2827
+ return retHash
2828
+ end
2829
+
2730
2830
  def query_offset_limit(sql, offset, limit)
2731
2831
  if (!limit.nil?)
2732
2832
  sql << " FETCH FIRST #{limit} ROWS ONLY"
@@ -2889,6 +2989,22 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2889
2989
  return "double precision"
2890
2990
  end
2891
2991
 
2992
+ def get_limit_offset_clauses(limit, offset)
2993
+ retHash = {"startSegment" => "", "endSegment" => ""}
2994
+ if limit != 0
2995
+ if !offset.nil?
2996
+ # Modifying the SQL to utilize the skip and limit amounts
2997
+ retHash["startSegment"] = " SELECT SKIP #{offset} LIMIT #{limit} "
2998
+ else
2999
+ # Modifying the SQL to retrieve only the first #{limit} rows
3000
+ retHash["startSegment"] = " SELECT FIRST #{limit} "
3001
+ end
3002
+ else
3003
+ retHash["startSegment"] = " SELECT * FROM (SELECT "
3004
+ retHash["endSegment"] = " ) WHERE 0 = 1 "
3005
+ end
3006
+ end
3007
+
2892
3008
  # Handling offset/limit as per Informix requirements
2893
3009
  def query_offset_limit(sql, offset, limit)
2894
3010
  if limit != 0
@@ -2968,11 +3084,39 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2968
3084
  end # module ActiveRecord
2969
3085
 
2970
3086
  module Arel
3087
+ #Check Arel version
3088
+ begin
3089
+ arelVersion = Arel::VERSION.to_i
3090
+ rescue
3091
+ arelVersion = 0
3092
+ end
3093
+ if(arelVersion >= 6)
3094
+ module Collectors
3095
+ class Bind
3096
+ def changeFirstSegment(segment)
3097
+ @parts[0] = segment
3098
+ end
3099
+
3100
+ def changeEndSegment(segment)
3101
+ len = @parts.length
3102
+ @parts[len] = segment
3103
+ end
3104
+ end
3105
+ end
3106
+ end
3107
+
2971
3108
  module Visitors
2972
3109
  class Visitor #opening and closing the class to ensure backward compatibility
2973
3110
  end
2974
-
2975
- class ToSql < Arel::Visitors::Visitor #opening and closing the class to ensure backward compatibility
3111
+
3112
+ #Check Arel version
3113
+ begin
3114
+ arelVersion = Arel::VERSION.to_i
3115
+ rescue
3116
+ arelVersion = 0
3117
+ end
3118
+ if(arelVersion >= 6)
3119
+ class ToSql < Arel::Visitors::Reduce #opening and closing the class to ensure backward compatibility
2976
3120
  # In case when using Rails-2.3.x there is no arel used due to which the constructor has to be defined explicitly
2977
3121
  # to ensure the same code works on any version of Rails
2978
3122
 
@@ -2985,6 +3129,7 @@ module Arel
2985
3129
 
2986
3130
  if(@arelVersion >= 3)
2987
3131
  def initialize connection
3132
+ super()
2988
3133
  @connection = connection
2989
3134
  @schema_cache = connection.schema_cache if(connection.respond_to?(:schema_cache))
2990
3135
  @quoted_tables = {}
@@ -2993,18 +3138,52 @@ module Arel
2993
3138
  end
2994
3139
  end
2995
3140
  end
3141
+ else
3142
+ class ToSql < Arel::Visitors::Visitor #opening and closing the class to ensure backward compatibility
3143
+ # In case when using Rails-2.3.x there is no arel used due to which the constructor has to be defined explicitly
3144
+ # to ensure the same code works on any version of Rails
3145
+
3146
+ #Check Arel version
3147
+ begin
3148
+ @arelVersion = Arel::VERSION.to_i
3149
+ rescue
3150
+ @arelVersion = 0
3151
+ end
3152
+ if(@arelVersion >= 3)
3153
+ def initialize connection
3154
+ super()
3155
+ @connection = connection
3156
+ @schema_cache = connection.schema_cache if(connection.respond_to?(:schema_cache))
3157
+ @quoted_tables = {}
3158
+ @quoted_columns = {}
3159
+ @last_column = nil
3160
+ end
3161
+
3162
+ end
3163
+ end
3164
+
3165
+ end
3166
+
2996
3167
 
2997
3168
  class IBM_DB < Arel::Visitors::ToSql
2998
3169
  private
2999
3170
 
3000
- def visit_Arel_Nodes_Limit o, a=nil
3171
+
3172
+ #Check Arel version
3173
+ begin
3174
+ @arelVersion = Arel::VERSION.to_i
3175
+ rescue
3176
+ @arelVersion = 0
3177
+ end
3178
+ if(@arelVersion < 6)
3179
+
3180
+ def visit_Arel_Nodes_Limit o, a=nil
3001
3181
  visit o.expr
3002
3182
  end
3003
3183
 
3004
3184
  def visit_Arel_Nodes_Offset o, a=nil
3005
3185
  visit o.expr
3006
3186
  end
3007
-
3008
3187
  def visit_Arel_Nodes_SelectStatement o, a=nil
3009
3188
  #Interim fix for backward compatibility [Arel 4.0.0 and below]
3010
3189
  if self.method(:visit_Arel_Nodes_SelectCore).arity == 1
@@ -3036,7 +3215,71 @@ module Arel
3036
3215
  sql << " #{(visit(o.lock) if o.lock)}"
3037
3216
  return sql
3038
3217
  end
3218
+ else
3219
+ def visit_Arel_Nodes_Limit o,collector
3220
+ visit o.expr, collector
3221
+ end
3039
3222
 
3223
+ def visit_Arel_Nodes_Offset o,collector
3224
+ visit o.expr,collector
3225
+ end
3226
+
3227
+ def visit_Arel_Nodes_SelectStatement o, collector
3228
+
3229
+ if o.with
3230
+ collector = visit o.with, collector
3231
+ collector << SPACE
3232
+ end
3233
+
3234
+ collector = o.cores.inject(collector) { |c,x|
3235
+ visit_Arel_Nodes_SelectCore(x, c)
3236
+ }
3237
+
3238
+ unless o.orders.empty?
3239
+ collector << SPACE
3240
+ collector << ORDER_BY
3241
+ len = o.orders.length - 1
3242
+ o.orders.each_with_index { |x, i|
3243
+ collector = visit(x, collector)
3244
+ collector << COMMA unless len == i
3245
+ }
3246
+ end
3247
+
3248
+ if o.limit
3249
+ limcoll = Arel::Collectors::SQLString.new
3250
+ visit(o.limit,limcoll)
3251
+ limit = limcoll.value.to_i
3252
+ else
3253
+ limit = nil
3254
+ end
3255
+
3256
+ if o.offset
3257
+ offcoll = Arel::Collectors::SQLString.new
3258
+ visit(o.offset,offcoll)
3259
+ offset = offcoll.value.to_i
3260
+ else
3261
+ offset = nil
3262
+ end
3263
+
3264
+ limOffClause = @connection.get_limit_offset_clauses(limit,offset)
3265
+
3266
+ if( !limOffClause["startSegment"].empty? )
3267
+ collector.changeFirstSegment(limOffClause["startSegment"])
3268
+ end
3269
+
3270
+ if( !limOffClause["endSegment"].empty? )
3271
+ collector.changeEndSegment(limOffClause["endSegment"])
3272
+ end
3273
+
3274
+ #Initialize a new Collector and set its value to the sql string built so far with any limit and ofset modifications
3275
+ #collector.reset(sql)
3276
+
3277
+ collector = maybe_visit o.lock, collector
3278
+
3279
+ return collector
3280
+ end
3281
+ end
3282
+
3040
3283
  end
3041
3284
  end
3042
3285
  end
@@ -1,13 +1,31 @@
1
- if (RUBY_VERSION =~ /1.9/ )
1
+ if (RUBY_VERSION =~ /1.9./ )
2
2
  require 'mswin32/rb19x/ibm_db.so'
3
- elsif (RUBY_VERSION =~ /2./ )
3
+ elsif (RUBY_VERSION =~ /2.0./)
4
+ #Check if we are on 64-bit or 32-bit ruby and load binary accordingly
5
+ machine_bits = ['ibm'].pack('p').size * 8
6
+ if machine_bits == 64
7
+ #require 'mswin32/rb2x/x64/ibm_db.so'
8
+ raise NotImplementedError, "ibm_db with Ruby 2.0 64-bit on Windows platform is not supported. Refer to README for more details"
9
+ else
10
+ require 'mswin32/rb2x/i386/ibm_db.so'
11
+ end
12
+ elsif (RUBY_VERSION =~ /2.1./)
13
+ #Check if we are on 64-bit or 32-bit ruby and load binary accordingly
14
+ machine_bits = ['ibm'].pack('p').size * 8
15
+ if machine_bits == 64
16
+ #require 'mswin32/rb21x/x64/ibm_db.so'
17
+ raise NotImplementedError, "ibm_db with Ruby 2.0 64-bit on Windows platform is not supported. Refer to README for more details"
18
+ else
19
+ require 'mswin32/rb21x/i386/ibm_db.so'
20
+ end
21
+ elsif (RUBY_VERSION =~ /2.2./ )
4
22
  #Check if we are on 64-bit or 32-bit ruby and load binary accordingly
5
23
  machine_bits = ['ibm'].pack('p').size * 8
6
24
  if machine_bits == 64
7
- #require 'mswin32/rb2x/x64/ibm_db.so'
25
+ #require 'mswin32/rb22x/x64/ibm_db.so'
8
26
  raise NotImplementedError, "ibm_db with Ruby 2.0 64-bit on Windows platform is not supported. Refer to README for more details"
9
27
  else
10
- require 'mswin32/rb2x/i386/ibm_db.so'
28
+ require 'mswin32/rb22x/i386/ibm_db.so'
11
29
  end
12
30
  else
13
31
  require 'mswin32/rb18x/ibm_db.so'
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.18
4
+ version: 2.5.25
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - IBM
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.15.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.15.1
27
27
  description:
@@ -34,27 +34,28 @@ extra_rdoc_files:
34
34
  - MANIFEST
35
35
  files:
36
36
  - CHANGES
37
- - ext/extconf.rb
38
- - ext/ibm_db.c
37
+ - LICENSE
38
+ - MANIFEST
39
+ - ParameterizedQueries README
40
+ - README
39
41
  - ext/Makefile.nt32
40
42
  - ext/Makefile.nt32.191
43
+ - ext/extconf.rb
44
+ - ext/ibm_db.c
41
45
  - ext/ruby_ibm_db.h
42
46
  - ext/ruby_ibm_db_cli.c
43
47
  - ext/ruby_ibm_db_cli.h
44
48
  - init.rb
45
- - lib/active_record/connection_adapters/ibmdb_adapter.rb
49
+ - lib/IBM_DB.rb
46
50
  - lib/active_record/connection_adapters/ibm_db_adapter.rb
47
51
  - lib/active_record/connection_adapters/ibm_db_pstmt.rb
52
+ - lib/active_record/connection_adapters/ibmdb_adapter.rb
48
53
  - lib/active_record/vendor/db2-i5-zOS.yaml
49
- - lib/IBM_DB.rb
50
54
  - lib/mswin32/ibm_db.rb
51
- - lib/mswin32/rb18x/ibm_db.so
52
55
  - lib/mswin32/rb19x/ibm_db.so
56
+ - lib/mswin32/rb21x/i386/ibm_db.so
57
+ - lib/mswin32/rb22x/i386/ibm_db.so
53
58
  - lib/mswin32/rb2x/i386/ibm_db.so
54
- - LICENSE
55
- - MANIFEST
56
- - ParameterizedQueries README
57
- - README
58
59
  - test/cases/adapter_test.rb
59
60
  - test/cases/associations/belongs_to_associations_test.rb
60
61
  - test/cases/associations/cascaded_eager_loading_test.rb
@@ -94,18 +95,18 @@ require_paths:
94
95
  - lib
95
96
  required_ruby_version: !ruby/object:Gem::Requirement
96
97
  requirements:
97
- - - '>='
98
+ - - ">="
98
99
  - !ruby/object:Gem::Version
99
100
  version: 1.8.6
100
101
  required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
- - - '>='
103
+ - - ">="
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements:
106
107
  - ActiveRecord, at least 1.15.1
107
108
  rubyforge_project: rubyibm
108
- rubygems_version: 2.0.14
109
+ rubygems_version: 2.4.5
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: 'Rails Driver and Adapter for IBM Data Servers: {DB2 on Linux/Unix/Windows,