activerecord-jdbc-adapter 1.1.2 → 1.1.3

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,3 +1,12 @@
1
+ == 1.1.3
2
+
3
+ - Remove AR version < 3 guard around some caching methods (sugg. invadersmustdie)
4
+ - Small bug in arjdbc/discover logic, thanks autotelik.
5
+ - Added bigint serial support + some testcases for native type mapping (postgres only)
6
+ - mssql: use subscript instead of #first. (Kim Toms)
7
+ - #71: fix yield called out of block error
8
+ - Silence Rake::DSL warnings for Rake > 0.9
9
+
1
10
  == 1.1.2
2
11
 
3
12
  - Update version of H2 driver from 1.1.107 to 1.3.153 (Ketan
@@ -125,6 +125,7 @@ test/postgres_db_create_test.rb
125
125
  test/postgres_drop_db_test.rb
126
126
  test/postgres_information_schema_leak_test.rb
127
127
  test/postgres_mixed_case_test.rb
128
+ test/postgres_native_type_mapping_test.rb
128
129
  test/postgres_nonseq_pkey_test.rb
129
130
  test/postgres_reserved_test.rb
130
131
  test/postgres_schema_search_path_test.rb
@@ -202,16 +202,14 @@ module ActiveRecord
202
202
  select(sql, name)
203
203
  end
204
204
 
205
- if ActiveRecord::VERSION::MAJOR < 3
206
- # Allow query caching to work even when we override alias_method_chain'd methods
207
- alias_chained_method :select_all, :query_cache, :jdbc_select_all
208
- alias_chained_method :update, :query_dirty, :jdbc_update
209
- alias_chained_method :insert, :query_dirty, :jdbc_insert
210
-
211
- # Do we need this? Not in AR 3.
212
- def select_one(sql, name = nil)
213
- select(sql, name).first
214
- end
205
+ # Allow query caching to work even when we override alias_method_chain'd methods
206
+ alias_chained_method :select_all, :query_cache, :jdbc_select_all
207
+ alias_chained_method :update, :query_dirty, :jdbc_update
208
+ alias_chained_method :insert, :query_dirty, :jdbc_insert
209
+
210
+ # Do we need this? Not in AR 3.
211
+ def select_one(sql, name = nil)
212
+ select(sql, name).first
215
213
  end
216
214
 
217
215
  def select_rows(sql, name = nil)
@@ -88,10 +88,10 @@ module ActiveRecord
88
88
  rescue ::ActiveRecord::ActiveRecordError
89
89
  raise
90
90
  rescue Exception => e
91
- raise ::ActiveRecord::JDBCError.new("The driver encountered an unknown error: #{e}").tap do |err|
91
+ raise ::ActiveRecord::JDBCError.new("The driver encountered an unknown error: #{e}").tap { |err|
92
92
  err.errno = 0
93
93
  err.sql_exception = e
94
- end
94
+ }
95
95
  end
96
96
 
97
97
  def adapter=(adapter)
@@ -5,7 +5,7 @@ module ArJdbc
5
5
  else
6
6
  files = $LOAD_PATH.map do |p|
7
7
  discover = File.join(p, 'arjdbc','discover.rb')
8
- File.exist?(p) ? discover : nil
8
+ File.exist?(discover) ? discover : nil
9
9
  end.compact
10
10
  end
11
11
  files.each do |f|
@@ -69,10 +69,10 @@ module ::ArJdbc
69
69
  find_select = /\b(SELECT(?:\s+DISTINCT)?)\b(.*)/im
70
70
  whole, select, rest_of_query = find_select.match(sql).to_a
71
71
  rest_of_query.strip!
72
- if rest_of_query.first == "1"
72
+ if rest_of_query[0] == "1"
73
73
  rest_of_query[0] = "*"
74
74
  end
75
- if rest_of_query.first == "*"
75
+ if rest_of_query[0] == "*"
76
76
  from_table = LimitHelpers.get_table_name(rest_of_query)
77
77
  rest_of_query = from_table + '.' + rest_of_query
78
78
  end
@@ -41,7 +41,7 @@ module ::ArJdbc
41
41
  end
42
42
 
43
43
  def simplified_type(field_type)
44
- return :integer if field_type =~ /^serial/i
44
+ return :integer if field_type =~ /^(big|)serial/i
45
45
  return :string if field_type =~ /\[\]$/i || field_type =~ /^interval/i
46
46
  return :string if field_type =~ /^(?:point|lseg|box|"?path"?|polygon|circle)/i
47
47
  return :datetime if field_type =~ /^timestamp/i
@@ -1,6 +1,6 @@
1
1
  module ArJdbc
2
2
  module Version
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
6
6
  # Compatibility with older versions of ar-jdbc for other extensions out there
@@ -15,6 +15,10 @@ module Rails
15
15
  end
16
16
 
17
17
  module AbstractDbCreate
18
+ def self.included(base)
19
+ base.module_eval { include Rake::DSL } if defined?(Rake::DSL)
20
+ end
21
+
18
22
  def setup
19
23
  @prevapp = Rake.application
20
24
  Rake.application = Rake::Application.new
@@ -0,0 +1,84 @@
1
+ require 'jdbc_common'
2
+ require 'db/postgres'
3
+
4
+ class CreateNativeTypeMappingTestSchema < ActiveRecord::Migration
5
+ def self.up
6
+ execute "DROP SEQUENCE IF EXISTS seq_pk_customers"
7
+ execute "CREATE SEQUENCE seq_pk_customers"
8
+ execute %q{
9
+ CREATE TABLE customers (
10
+ bigint_serial_should_be_integer bigint default nextval('seq_pk_customers'),
11
+ integer_serial_should_be_integer integer default nextval('seq_pk_customers'),
12
+ varchar_should_be_string varchar(2),
13
+ timestamp_should_be_datetime timestamp,
14
+ bytea_should_be_binary bytea,
15
+ double_precision_should_be_float double precision,
16
+ real_should_be_float real,
17
+ bool_should_be_boolean bool,
18
+ interval_should_be_string interval,
19
+ bigint_should_be_integer bigint
20
+ )}
21
+ end
22
+
23
+ def self.down
24
+ execute "DROP TABLE customers"
25
+ execute "DROP SEQUENCE IF EXISTS seq_pk_customers"
26
+ end
27
+ end
28
+
29
+ class Customer < ActiveRecord::Base
30
+ end
31
+
32
+ class PostgresNativeTypeMappingTest < Test::Unit::TestCase
33
+ def setup
34
+ CreateNativeTypeMappingTestSchema.up
35
+ end
36
+
37
+ def teardown
38
+ CreateNativeTypeMappingTestSchema.down
39
+ end
40
+
41
+ def column_type(column_name)
42
+ Customer.columns.detect { |c| c.name == column_name }.type
43
+ end
44
+
45
+ def test_bigint_serial_should_be_mapped_to_integer
46
+ assert_equal :integer, column_type("bigint_serial_should_be_integer")
47
+ end
48
+
49
+ def test_integer_serial_should_be_mapped_to_integer
50
+ assert_equal :integer, column_type("integer_serial_should_be_integer")
51
+ end
52
+
53
+ def test_varchar_should_be_mapped_to_string
54
+ assert_equal :string, column_type("varchar_should_be_string")
55
+ end
56
+
57
+ def test_timestamp_should_be_mapped_to_datetime
58
+ assert_equal :datetime, column_type("timestamp_should_be_datetime")
59
+ end
60
+
61
+ def test_bytea_should_be_mapped_to_binary
62
+ assert_equal :binary, column_type("bytea_should_be_binary")
63
+ end
64
+
65
+ def test_double_precision_should_be_mapped_to_float
66
+ assert_equal :float, column_type("double_precision_should_be_float")
67
+ end
68
+
69
+ def test_real_should_be_mapped_to_float
70
+ assert_equal :float, column_type("real_should_be_float")
71
+ end
72
+
73
+ def test_bool_should_be_mapped_to_boolean
74
+ assert_equal :boolean, column_type("bool_should_be_boolean")
75
+ end
76
+
77
+ def test_interval_should_be_mapped_to_string
78
+ assert_equal :string, column_type("interval_should_be_string")
79
+ end
80
+
81
+ def test_bigint_should_be_mapped_to_integer
82
+ assert_equal :integer, column_type("bigint_should_be_integer")
83
+ end
84
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.2
5
+ version: 1.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Sieger, Ola Bini and JRuby contributors
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-20 00:00:00 -05:00
13
+ date: 2011-07-26 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -177,6 +177,7 @@ files:
177
177
  - test/postgres_drop_db_test.rb
178
178
  - test/postgres_information_schema_leak_test.rb
179
179
  - test/postgres_mixed_case_test.rb
180
+ - test/postgres_native_type_mapping_test.rb
180
181
  - test/postgres_nonseq_pkey_test.rb
181
182
  - test/postgres_reserved_test.rb
182
183
  - test/postgres_schema_search_path_test.rb