activerecord-mysqlspatial-adapter 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 0.4.1 / 2012-02-22
2
+
3
+ * Some compatibility fixes for Rails 3.2. (Reported by Nicholas Zaillian and Ryan Williams with implementation help from Radek Paviensky.) The mysql gem issue remains, however, and I do not know of a workaround. Use activerecord-mysql2-adapter for now if you need Rails >= 3.1 support.
4
+ * Now requires rgeo-activerecord 0.4.3.
5
+
1
6
  === 0.4.0 / 2011-08-15
2
7
 
3
8
  * Various fixes towards Rails 3.1 compatibility. However, this adapter is not yet actually Rails 3.1 compatible because of a bug in the mysql gem. Use activerecord-mysql2-adapter for now if you need Rails 3.1 support.
@@ -94,10 +94,12 @@ write more complex queries in SQL.
94
94
 
95
95
  == Installation And Configuration
96
96
 
97
- IMPORTANT: This adapter is currently *not* compatible with Rails 3.1.
98
- This is due to an apparent bug in the mysql gem (as of version 2.8.1),
99
- which does not appear to recognize MYSQL_TYPE_GEOMETRY in the binary
100
- protocol.
97
+ IMPORTANT: This adapter is currently *not* compatible with Rails version
98
+ 3.1 and later. This is due to an apparent bug in the mysql gem (as of
99
+ version 2.8.1), which does not appear to recognize MYSQL_TYPE_GEOMETRY in
100
+ the binary protocol. I'm not aware of a workaround for this issue right
101
+ now. Please use mysql2 and activerecord-mysql2spatial-adapter if you are
102
+ using MySQL spatial and Rails 3.1 or later.
101
103
 
102
104
  === Installing The Adapter Gem
103
105
 
@@ -107,8 +109,8 @@ This adapter has the following requirements:
107
109
  * MySQL server 5.0 or later required for spatial extensions.
108
110
  * \ActiveRecord 3.0.3 or later. Earlier versions will not work.
109
111
  * mysql gem 2.8 or later.
110
- * rgeo gem 0.3.2 or later.
111
- * rgeo-activerecord gem 0.4.0 or later.
112
+ * rgeo gem 0.3.4 or later.
113
+ * rgeo-activerecord gem 0.4.3 or later.
112
114
 
113
115
  Install this adapter as a gem:
114
116
 
@@ -170,7 +172,7 @@ Contact the author at dazuma at gmail dot com.
170
172
  The MysqlSpatial Adapter and its supporting libraries (including RGeo) are
171
173
  written by Daniel Azuma (http://www.daniel-azuma.com).
172
174
 
173
- Development of RGeo is sponsored by GeoPage, Inc. (http://www.geopage.com).
175
+ Development is supported by Pirq. (http://www.pirq.com).
174
176
 
175
177
  This adapter implementation owes some debt to the spatial_adapter plugin
176
178
  (http://github.com/fragility/spatial_adapter). Although we made a few
data/Version CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # MysqlSpatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,16 +42,16 @@ require 'active_record/connection_adapters/mysql_adapter'
42
42
  # connection adapter into ActiveRecord.
43
43
 
44
44
  module ActiveRecord
45
-
46
-
45
+
46
+
47
47
  # ActiveRecord looks for the mysqlspatial_connection factory method in
48
48
  # this class.
49
-
49
+
50
50
  class Base
51
-
52
-
51
+
52
+
53
53
  # Create a mysqlspatial connection adapter.
54
-
54
+
55
55
  def self.mysqlspatial_connection(config_)
56
56
  unless defined?(::Mysql)
57
57
  begin
@@ -71,25 +71,25 @@ module ActiveRecord
71
71
  options_ = [config_[:host], config_[:username] ? config_[:username].to_s : 'root', config_[:password].to_s, config_[:database], config_[:port], config_[:socket], default_flags_]
72
72
  ::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::MainAdapter.new(mysql_, logger, options_, config_)
73
73
  end
74
-
75
-
74
+
75
+
76
76
  end
77
-
78
-
77
+
78
+
79
79
  # All ActiveRecord adapters go in this namespace.
80
80
  module ConnectionAdapters
81
-
81
+
82
82
  # The MysqlSpatial adapter
83
83
  module MysqlSpatialAdapter
84
-
84
+
85
85
  # The name returned by the adapter_name method of this adapter.
86
86
  ADAPTER_NAME = 'MysqlSpatial'.freeze
87
-
87
+
88
88
  end
89
-
89
+
90
90
  end
91
-
92
-
91
+
92
+
93
93
  end
94
94
 
95
95
 
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # MysqlSpatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,17 +38,17 @@
38
38
 
39
39
  module Arel
40
40
  module Visitors
41
-
41
+
42
42
  class MySQLSpatial < MySQL
43
-
43
+
44
44
  FUNC_MAP = {
45
45
  'st_wkttosql' => 'GeomFromText',
46
46
  'st_wkbtosql' => 'GeomFromWKB',
47
47
  'st_length' => 'GLength',
48
48
  }
49
-
49
+
50
50
  include ::RGeo::ActiveRecord::SpatialToSql
51
-
51
+
52
52
  def st_func(standard_name_)
53
53
  if (name_ = FUNC_MAP[standard_name_.downcase])
54
54
  name_
@@ -58,11 +58,11 @@ module Arel
58
58
  standard_name_
59
59
  end
60
60
  end
61
-
61
+
62
62
  end
63
-
63
+
64
64
  VISITORS['mysqlspatial'] = ::Arel::Visitors::MySQLSpatial
65
-
65
+
66
66
  end
67
67
  end
68
68
 
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # MysqlSpatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,38 +37,47 @@
37
37
  # :stopdoc:
38
38
 
39
39
  module ActiveRecord
40
-
40
+
41
41
  module ConnectionAdapters
42
-
42
+
43
43
  module MysqlSpatialAdapter
44
-
45
-
44
+
45
+
46
46
  class MainAdapter < ConnectionAdapters::MysqlAdapter
47
-
48
-
47
+
48
+
49
49
  NATIVE_DATABASE_TYPES = MysqlAdapter::NATIVE_DATABASE_TYPES.merge(:spatial => {:name => "geometry"})
50
-
51
-
50
+
51
+
52
+ def initialize(*args_)
53
+ super
54
+ # Rails 3.2 way of defining the visitor: do so in the constructor
55
+ if defined?(@visitor) && @visitor
56
+ @visitor = ::Arel::Visitors::MySQLSpatial.new(self)
57
+ end
58
+ end
59
+
60
+
52
61
  def set_rgeo_factory_settings(factory_settings_)
53
62
  @rgeo_factory_settings = factory_settings_
54
63
  end
55
-
56
-
64
+
65
+
57
66
  def adapter_name
58
67
  MysqlSpatialAdapter::ADAPTER_NAME
59
68
  end
60
-
61
-
69
+
70
+
62
71
  def spatial_column_constructor(name_)
63
72
  ::RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name_]
64
73
  end
65
-
66
-
74
+
75
+
67
76
  def native_database_types
68
77
  NATIVE_DATABASE_TYPES
69
78
  end
70
-
71
-
79
+
80
+
72
81
  def quote(value_, column_=nil)
73
82
  if ::RGeo::Feature::Geometry.check_type(value_)
74
83
  "GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(:hex_format => true).generate(value_)},#{value_.srid})"
@@ -76,8 +85,8 @@ module ActiveRecord
76
85
  super
77
86
  end
78
87
  end
79
-
80
-
88
+
89
+
81
90
  def substitute_at(column_, index_)
82
91
  if column_.spatial?
83
92
  ::Arel.sql('GeomFromText(?,?)')
@@ -85,8 +94,8 @@ module ActiveRecord
85
94
  super
86
95
  end
87
96
  end
88
-
89
-
97
+
98
+
90
99
  def type_cast(value_, column_)
91
100
  if column_.spatial? && ::RGeo::Feature::Geometry.check_type(value_)
92
101
  ::RGeo::WKRep::WKTGenerator.new.generate(value_)
@@ -94,8 +103,8 @@ module ActiveRecord
94
103
  super
95
104
  end
96
105
  end
97
-
98
-
106
+
107
+
99
108
  def exec_stmt(sql_, name_, binds_)
100
109
  real_binds_ = []
101
110
  binds_.each do |bind_|
@@ -108,8 +117,8 @@ module ActiveRecord
108
117
  end
109
118
  super(sql_, name_, real_binds_)
110
119
  end
111
-
112
-
120
+
121
+
113
122
  def type_to_sql(type_, limit_=nil, precision_=nil, scale_=nil)
114
123
  if (info_ = spatial_column_constructor(type_.to_sym))
115
124
  type_ = limit_[:type] || type_ if limit_.is_a?(::Hash)
@@ -118,8 +127,8 @@ module ActiveRecord
118
127
  end
119
128
  super(type_, limit_, precision_, scale_)
120
129
  end
121
-
122
-
130
+
131
+
123
132
  def add_index(table_name_, column_name_, options_={})
124
133
  if options_[:spatial]
125
134
  index_name_ = index_name(table_name_, :column => Array(column_name_))
@@ -131,8 +140,8 @@ module ActiveRecord
131
140
  super
132
141
  end
133
142
  end
134
-
135
-
143
+
144
+
136
145
  def columns(table_name_, name_=nil)
137
146
  result_ = execute("SHOW FIELDS FROM #{quote_table_name(table_name_)}", :skip_logging)
138
147
  columns_ = []
@@ -143,8 +152,8 @@ module ActiveRecord
143
152
  result_.free
144
153
  columns_
145
154
  end
146
-
147
-
155
+
156
+
148
157
  def indexes(table_name_, name_=nil)
149
158
  indexes_ = []
150
159
  current_index_ = nil
@@ -162,15 +171,15 @@ module ActiveRecord
162
171
  result_.free
163
172
  indexes_
164
173
  end
165
-
166
-
174
+
175
+
167
176
  end
168
-
169
-
177
+
178
+
170
179
  end
171
-
180
+
172
181
  end
173
-
182
+
174
183
  end
175
184
 
176
185
  # :startdoc:
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # MysqlSpatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,15 +37,23 @@
37
37
  # :stopdoc:
38
38
 
39
39
  module ActiveRecord
40
-
40
+
41
41
  module ConnectionAdapters
42
-
42
+
43
43
  module MysqlSpatialAdapter
44
-
45
-
46
- class SpatialColumn < ConnectionAdapters::MysqlColumn
47
-
48
-
44
+
45
+
46
+ # ActiveRecord 3.2 uses ConnectionAdapters::MysqlAdapter::Column
47
+ # whereas 3.0 and 3.1 use ConnectionAdapters::MysqlColumn
48
+ column_base_class_ = defined?(ConnectionAdapters::MysqlAdapter::Column) ?
49
+ ConnectionAdapters::MysqlAdapter::Column : ConnectionAdapters::MysqlColumn
50
+
51
+ class SpatialColumn < column_base_class_
52
+
53
+
54
+ FACTORY_SETTINGS_CACHE = {}
55
+
56
+
49
57
  def initialize(factory_settings_, table_name_, name_, default_, sql_type_=nil, null_=true)
50
58
  @factory_settings = factory_settings_
51
59
  @table_name = table_name_
@@ -54,22 +62,23 @@ module ActiveRecord
54
62
  if type == :spatial
55
63
  @limit = {:type => @geometric_type.type_name.underscore}
56
64
  end
65
+ FACTORY_SETTINGS_CACHE[factory_settings_.object_id] = factory_settings_
57
66
  end
58
-
59
-
67
+
68
+
60
69
  attr_reader :geometric_type
61
-
62
-
70
+
71
+
63
72
  def spatial?
64
73
  type == :spatial
65
74
  end
66
-
67
-
75
+
76
+
68
77
  def klass
69
78
  type == :spatial ? ::RGeo::Feature::Geometry : super
70
79
  end
71
-
72
-
80
+
81
+
73
82
  def type_cast(value_)
74
83
  if type == :spatial
75
84
  SpatialColumn.convert_to_geometry(value_, @factory_settings, @table_name, name)
@@ -77,25 +86,26 @@ module ActiveRecord
77
86
  super
78
87
  end
79
88
  end
80
-
81
-
89
+
90
+
82
91
  def type_cast_code(var_name_)
83
92
  if type == :spatial
84
93
  "::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::SpatialColumn.convert_to_geometry("+
85
- "#{var_name_}, self.class.rgeo_factory_settings, self.class.table_name, #{name.inspect})"
94
+ "#{var_name_}, ::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::SpatialColumn::"+
95
+ "FACTORY_SETTINGS_CACHE[#{@factory_settings.object_id}], #{@table_name.inspect}, #{name.inspect})"
86
96
  else
87
97
  super
88
98
  end
89
99
  end
90
-
91
-
100
+
101
+
92
102
  private
93
-
103
+
94
104
  def simplified_type(sql_type_)
95
105
  sql_type_ =~ /geometry|point|linestring|polygon/i ? :spatial : super
96
106
  end
97
-
98
-
107
+
108
+
99
109
  def self.convert_to_geometry(input_, factory_settings_, table_name_, column_)
100
110
  case input_
101
111
  when ::RGeo::Feature::Geometry
@@ -122,15 +132,15 @@ module ActiveRecord
122
132
  nil
123
133
  end
124
134
  end
125
-
126
-
135
+
136
+
127
137
  end
128
-
129
-
138
+
139
+
130
140
  end
131
-
141
+
132
142
  end
133
-
143
+
134
144
  end
135
145
 
136
146
  # :startdoc:
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # MysqlSpatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,22 +41,22 @@ end
41
41
 
42
42
 
43
43
  module ActiveRecord
44
-
44
+
45
45
  module ConnectionAdapters
46
-
46
+
47
47
  module MysqlSpatialAdapter
48
-
49
-
48
+
49
+
50
50
  # Current version of MysqlSpatialAdapter as a frozen string
51
51
  VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../../../Version').strip.freeze
52
-
52
+
53
53
  # Current version of MysqlSpatialAdapter as a Versionomy object, if the
54
54
  # Versionomy gem is available; otherwise equal to VERSION_STRING.
55
55
  VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING) : VERSION_STRING
56
-
57
-
56
+
57
+
58
58
  end
59
-
59
+
60
60
  end
61
-
61
+
62
62
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for the MysqlSpatial ActiveRecord adapter
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,15 +41,15 @@ module RGeo
41
41
  module ActiveRecord # :nodoc:
42
42
  module MysqlSpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestBasic < ::Test::Unit::TestCase # :nodoc:
46
-
46
+
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
48
  include AdapterTestHelper
49
-
49
+
50
50
  define_test_methods do
51
-
52
-
51
+
52
+
53
53
  def populate_ar_class(content_)
54
54
  klass_ = create_ar_class
55
55
  case content_
@@ -60,13 +60,13 @@ module RGeo
60
60
  end
61
61
  klass_
62
62
  end
63
-
64
-
63
+
64
+
65
65
  def test_version
66
66
  assert_not_nil(::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::VERSION)
67
67
  end
68
-
69
-
68
+
69
+
70
70
  def test_create_simple_geometry
71
71
  klass_ = create_ar_class
72
72
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -75,8 +75,8 @@ module RGeo
75
75
  assert_equal(::RGeo::Feature::Geometry, klass_.columns.last.geometric_type)
76
76
  assert(klass_.cached_attributes.include?('latlon'))
77
77
  end
78
-
79
-
78
+
79
+
80
80
  def test_create_point_geometry
81
81
  klass_ = create_ar_class
82
82
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -85,8 +85,8 @@ module RGeo
85
85
  assert_equal(::RGeo::Feature::Point, klass_.columns.last.geometric_type)
86
86
  assert(klass_.cached_attributes.include?('latlon'))
87
87
  end
88
-
89
-
88
+
89
+
90
90
  def test_create_geometry_with_index
91
91
  klass_ = create_ar_class
92
92
  klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
@@ -97,8 +97,8 @@ module RGeo
97
97
  end
98
98
  assert(klass_.connection.indexes(:spatial_test).last.spatial)
99
99
  end
100
-
101
-
100
+
101
+
102
102
  def test_set_and_get_point
103
103
  klass_ = populate_ar_class(:latlon_point)
104
104
  obj_ = klass_.new
@@ -107,8 +107,8 @@ module RGeo
107
107
  assert_equal(@factory.point(1, 2), obj_.latlon)
108
108
  assert_equal(3785, obj_.latlon.srid)
109
109
  end
110
-
111
-
110
+
111
+
112
112
  def test_set_and_get_point_from_wkt
113
113
  klass_ = populate_ar_class(:latlon_point)
114
114
  obj_ = klass_.new
@@ -117,8 +117,8 @@ module RGeo
117
117
  assert_equal(@factory.point(1, 2), obj_.latlon)
118
118
  assert_equal(1000, obj_.latlon.srid)
119
119
  end
120
-
121
-
120
+
121
+
122
122
  def test_save_and_load_point
123
123
  klass_ = populate_ar_class(:latlon_point)
124
124
  obj_ = klass_.new
@@ -129,8 +129,8 @@ module RGeo
129
129
  assert_equal(@factory.point(1, 2), obj2_.latlon)
130
130
  assert_equal(3785, obj2_.latlon.srid)
131
131
  end
132
-
133
-
132
+
133
+
134
134
  def test_save_and_load_point_from_wkt
135
135
  klass_ = populate_ar_class(:latlon_point)
136
136
  obj_ = klass_.new
@@ -141,8 +141,8 @@ module RGeo
141
141
  assert_equal(@factory.point(1, 2), obj2_.latlon)
142
142
  assert_equal(1000, obj2_.latlon.srid)
143
143
  end
144
-
145
-
144
+
145
+
146
146
  def test_readme_example
147
147
  klass_ = create_ar_class
148
148
  klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
@@ -164,8 +164,8 @@ module RGeo
164
164
  rec_.shape = loc_
165
165
  assert_equal(true, ::RGeo::Geos.is_geos?(rec_.shape))
166
166
  end
167
-
168
-
167
+
168
+
169
169
  def test_create_simple_geometry_using_shortcut
170
170
  klass_ = create_ar_class
171
171
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -174,8 +174,8 @@ module RGeo
174
174
  assert_equal(::RGeo::Feature::Geometry, klass_.columns.last.geometric_type)
175
175
  assert(klass_.cached_attributes.include?('latlon'))
176
176
  end
177
-
178
-
177
+
178
+
179
179
  def test_create_point_geometry_using_shortcut
180
180
  klass_ = create_ar_class
181
181
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -184,8 +184,8 @@ module RGeo
184
184
  assert_equal(::RGeo::Feature::Point, klass_.columns.last.geometric_type)
185
185
  assert(klass_.cached_attributes.include?('latlon'))
186
186
  end
187
-
188
-
187
+
188
+
189
189
  def test_create_geometry_using_limit
190
190
  klass_ = create_ar_class
191
191
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -194,12 +194,12 @@ module RGeo
194
194
  assert_equal(::RGeo::Feature::LineString, klass_.columns.last.geometric_type)
195
195
  assert(klass_.cached_attributes.include?('geom'))
196
196
  end
197
-
198
-
197
+
198
+
199
199
  end
200
-
200
+
201
201
  end
202
-
202
+
203
203
  end
204
204
  end
205
205
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for the MysqlSpatial ActiveRecord adapter
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,15 +41,15 @@ module RGeo
41
41
  module ActiveRecord # :nodoc:
42
42
  module MysqlSpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestSpatialQueries < ::Test::Unit::TestCase # :nodoc:
46
-
46
+
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
48
  include AdapterTestHelper
49
-
49
+
50
50
  define_test_methods do
51
-
52
-
51
+
52
+
53
53
  def populate_ar_class(content_)
54
54
  klass_ = create_ar_class
55
55
  case content_
@@ -64,8 +64,8 @@ module RGeo
64
64
  end
65
65
  klass_
66
66
  end
67
-
68
-
67
+
68
+
69
69
  def test_query_point
70
70
  klass_ = populate_ar_class(:latlon_point)
71
71
  obj_ = klass_.new
@@ -77,8 +77,8 @@ module RGeo
77
77
  obj3_ = klass_.where(:latlon => @factory.point(2, 2)).first
78
78
  assert_nil(obj3_)
79
79
  end
80
-
81
-
80
+
81
+
82
82
  def _test_query_point_wkt
83
83
  klass_ = populate_ar_class(:latlon_point)
84
84
  obj_ = klass_.new
@@ -90,11 +90,11 @@ module RGeo
90
90
  obj3_ = klass_.where(:latlon => 'POINT(2 2)').first
91
91
  assert_nil(obj3_)
92
92
  end
93
-
94
-
93
+
94
+
95
95
  if ::RGeo::ActiveRecord.spatial_expressions_supported?
96
-
97
-
96
+
97
+
98
98
  def test_query_st_length
99
99
  klass_ = populate_ar_class(:path_linestring)
100
100
  obj_ = klass_.new
@@ -106,19 +106,19 @@ module RGeo
106
106
  obj3_ = klass_.where(klass_.arel_table[:path].st_length.gt(3)).first
107
107
  assert_nil(obj3_)
108
108
  end
109
-
110
-
109
+
110
+
111
111
  else
112
-
112
+
113
113
  puts "WARNING: The current Arel does not support named functions. Spatial expression tests skipped."
114
-
114
+
115
115
  end
116
-
117
-
116
+
117
+
118
118
  end
119
-
119
+
120
120
  end
121
-
121
+
122
122
  end
123
123
  end
124
124
  end
metadata CHANGED
@@ -1,49 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysqlspatial-adapter
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
4
5
  prerelease:
5
- version: 0.4.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Daniel Azuma
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-08-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rgeo-activerecord
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2155892340 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 0.4.0
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.3
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: mysql
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2155892340
25
+ - !ruby/object:Gem::Dependency
26
+ name: mysql
27
+ requirement: &2155891100 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
34
32
  version: 2.8.1
35
33
  type: :runtime
36
- version_requirements: *id002
37
- description: This is an ActiveRecord connection adapter for MySQL Spatial Extensions. It is based on the stock MySQL adapter, but provides built-in support for spatial columns. It uses the RGeo library to represent spatial data in Ruby.
34
+ prerelease: false
35
+ version_requirements: *2155891100
36
+ description: This is an ActiveRecord connection adapter for MySQL Spatial Extensions.
37
+ It is based on the stock MySQL adapter, but provides built-in support for spatial
38
+ columns. It uses the RGeo library to represent spatial data in Ruby.
38
39
  email: dazuma@gmail.com
39
40
  executables: []
40
-
41
41
  extensions: []
42
-
43
- extra_rdoc_files:
42
+ extra_rdoc_files:
44
43
  - History.rdoc
45
44
  - README.rdoc
46
- files:
45
+ files:
47
46
  - lib/active_record/connection_adapters/mysqlspatial_adapter/arel_tosql.rb
48
47
  - lib/active_record/connection_adapters/mysqlspatial_adapter/main_adapter.rb
49
48
  - lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb
@@ -56,31 +55,29 @@ files:
56
55
  - Version
57
56
  homepage: http://virtuoso.rubyforge.org/activerecord-mysqlspatial-adapter
58
57
  licenses: []
59
-
60
58
  post_install_message:
61
59
  rdoc_options: []
62
-
63
- require_paths:
60
+ require_paths:
64
61
  - lib
65
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
66
63
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
70
67
  version: 1.8.7
71
- required_rubygems_version: !ruby/object:Gem::Requirement
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
69
  none: false
73
- requirements:
74
- - - ">"
75
- - !ruby/object:Gem::Version
70
+ requirements:
71
+ - - ! '>'
72
+ - !ruby/object:Gem::Version
76
73
  version: 1.3.1
77
74
  requirements: []
78
-
79
75
  rubyforge_project: virtuoso
80
- rubygems_version: 1.8.7
76
+ rubygems_version: 1.8.17
81
77
  signing_key:
82
78
  specification_version: 3
83
- summary: An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the mysql gem.
84
- test_files:
79
+ summary: An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the
80
+ mysql gem.
81
+ test_files:
85
82
  - test/tc_basic.rb
86
83
  - test/tc_spatial_queries.rb