activerecord-postgis-adapter 0.6.6 → 0.7.0
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 +4 -4
- data/History.rdoc +7 -0
- data/{lib/rgeo/active_record/postgis_adapter/railtie.rb → LICENSE.txt} +2 -12
- data/lib/active_record/connection_adapters/postgis_adapter.rb +1 -60
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/create_connection.rb +15 -74
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/databases.rake +0 -38
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/main_adapter.rb +0 -68
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/postgis_database_tasks.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_column.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_table_definition.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/railtie.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/shared/arel_tosql.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb +3 -70
- data/lib/active_record/connection_adapters/postgis_adapter/shared/railtie.rb +1 -54
- data/lib/active_record/connection_adapters/postgis_adapter/shared/setup.rb +0 -36
- data/lib/active_record/connection_adapters/postgis_adapter/version.rb +7 -0
- data/lib/activerecord-postgis-adapter.rb +0 -36
- data/lib/activerecord/postgis/adapter.rb +0 -36
- data/test/database.yml +5 -0
- data/test/tc_basic.rb +0 -35
- data/test/tc_ddl.rb +0 -35
- data/test/tc_nested_class.rb +0 -35
- data/test/tc_spatial_queries.rb +0 -35
- data/test/tc_tasks.rb +0 -78
- metadata +33 -38
- data/Version +0 -1
- data/lib/active_record/connection_adapters/postgis_adapter/rails3/create_connection.rb +0 -96
- data/lib/active_record/connection_adapters/postgis_adapter/rails3/databases.rake +0 -232
- data/lib/active_record/connection_adapters/postgis_adapter/rails3/main_adapter.rb +0 -298
- data/lib/active_record/connection_adapters/postgis_adapter/rails3/spatial_column.rb +0 -195
- data/lib/active_record/connection_adapters/postgis_adapter/rails3/spatial_table_definition.rb +0 -145
- data/lib/active_record/connection_adapters/postgis_adapter/shared/jdbc_compat.rb +0 -134
- data/lib/active_record/connection_adapters/postgis_adapter/shared/version.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e0e15e44b3ab31f823c3444c2d9c570c9ec05d
|
4
|
+
data.tar.gz: 2bd3b9721d10bdf3b50ed54ba58ab64f86ab7fbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58aeefe5d9a09e2cf98572cb858cedd6b3d6b2d246b21d4b2885be09c7c697f910fe185a5037da9ed8b49e9090e9fd6161e6da66ccdf0e0493c4edd7e1d42062
|
7
|
+
data.tar.gz: 54d2983b42788fa200f3c2d36ee5d0c84f96362d05d59576216ecd4a986de63756a134e308a614dfeec9e267d4fd57bc76978134f15be6268348fcd8342adada
|
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.7.0 / 2014-04-04
|
2
|
+
|
3
|
+
* Version 0.7.0 is for Rails 4.0.x
|
4
|
+
* Require ruby 1.9.3+
|
5
|
+
* Require ActiveRecord 4.0
|
6
|
+
* Drop JRuby support (temporary)
|
7
|
+
|
1
8
|
=== 0.6.5 / 2013-06-24
|
2
9
|
|
3
10
|
* Fixed stoopid syntax errors in rake db:gis:setup tass. (Pull requests by rhodrid and jdurand)
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Railtie for PostGIS adapter
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010-2012 Daniel Azuma
|
2
|
+
# Copyright 2012 Daniel Azuma
|
7
3
|
#
|
8
4
|
# All rights reserved.
|
9
5
|
#
|
@@ -30,10 +26,4 @@
|
|
30
26
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
27
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
28
|
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
|
-
puts 'WARNING: requiring "rgeo/active_record/postgis_adapter/railtie" is deprecated. Generally, the normal Bundle.require will do the trick. If you need to require the railtie explicitly, require "active_record/connection_adapters/postgis_adapter/railtie"'
|
38
|
-
|
39
|
-
require 'active_record/connection_adapters/postgis_adapter/railtie'
|
29
|
+
# -----------------------------------------------------------------------------
|
@@ -1,62 +1,18 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# PostGIS adapter for ActiveRecord
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010-2012 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
1
|
# The activerecord-postgis-adapter gem installs the *postgis*
|
38
2
|
# connection adapter into ActiveRecord.
|
39
3
|
|
40
4
|
module ActiveRecord
|
41
|
-
|
42
5
|
# All ActiveRecord adapters go in this namespace.
|
43
6
|
# This adapter is installed into the PostGISAdapter submodule.
|
44
7
|
module ConnectionAdapters
|
45
|
-
|
46
8
|
# The PostGIS Adapter lives in this namespace.
|
47
9
|
module PostGISAdapter
|
48
|
-
|
49
10
|
# The name returned by the adapter_name method of this adapter.
|
50
11
|
ADAPTER_NAME = 'PostGIS'.freeze
|
51
|
-
|
52
12
|
end
|
53
|
-
|
54
13
|
end
|
55
|
-
|
56
|
-
|
57
14
|
end
|
58
15
|
|
59
|
-
|
60
16
|
# :stopdoc:
|
61
17
|
|
62
18
|
require 'active_record'
|
@@ -64,23 +20,8 @@ require 'active_record/connection_adapters/postgresql_adapter'
|
|
64
20
|
require 'rgeo/active_record'
|
65
21
|
|
66
22
|
case ::ActiveRecord::VERSION::MAJOR
|
67
|
-
when 3
|
68
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/version.rb'
|
69
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb'
|
70
|
-
require 'active_record/connection_adapters/postgis_adapter/rails3/main_adapter.rb'
|
71
|
-
require 'active_record/connection_adapters/postgis_adapter/rails3/spatial_table_definition.rb'
|
72
|
-
require 'active_record/connection_adapters/postgis_adapter/rails3/spatial_column.rb'
|
73
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/arel_tosql.rb'
|
74
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/setup.rb'
|
75
|
-
require 'active_record/connection_adapters/postgis_adapter/rails3/create_connection'
|
76
23
|
when 4
|
77
|
-
|
78
|
-
# TEMP
|
79
|
-
if defined?(::RUBY_ENGINE) && ::RUBY_ENGINE == 'jruby'
|
80
|
-
raise "**** Sorry, activerecord-postgis-adapter does not yet support Rails 4 on JRuby ****"
|
81
|
-
end
|
82
|
-
|
83
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/version.rb'
|
24
|
+
require 'active_record/connection_adapters/postgis_adapter/version.rb'
|
84
25
|
require 'active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb'
|
85
26
|
require 'active_record/connection_adapters/postgis_adapter/rails4/main_adapter.rb'
|
86
27
|
require 'active_record/connection_adapters/postgis_adapter/rails4/spatial_table_definition.rb'
|
@@ -1,88 +1,29 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# PostGIS adapter for ActiveRecord
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010-2012 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
1
|
module ActiveRecord # :nodoc:
|
38
2
|
|
39
3
|
module ConnectionHandling # :nodoc:
|
4
|
+
require 'pg'
|
40
5
|
|
6
|
+
# Based on the default <tt>postgresql_connection</tt> definition from
|
7
|
+
# ActiveRecord.
|
41
8
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
require 'active_record/connection_adapters/postgis_adapter/shared/jdbc_compat'
|
46
|
-
|
47
|
-
|
48
|
-
def postgis_connection(config_)
|
49
|
-
::ActiveRecord::ConnectionAdapters::PostGISAdapter.create_jdbc_connection(self, config_)
|
50
|
-
end
|
51
|
-
|
52
|
-
alias_method :jdbcpostgis_connection, :postgis_connection
|
53
|
-
|
54
|
-
|
55
|
-
else
|
9
|
+
def postgis_connection(config_)
|
10
|
+
# FULL REPLACEMENT because we need to create a different class.
|
11
|
+
conn_params_ = config_.symbolize_keys
|
56
12
|
|
13
|
+
conn_params_.delete_if { |_, v_| v_.nil? }
|
57
14
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# Based on the default <tt>postgresql_connection</tt> definition from
|
62
|
-
# ActiveRecord.
|
63
|
-
|
64
|
-
def postgis_connection(config_)
|
65
|
-
# FULL REPLACEMENT because we need to create a different class.
|
66
|
-
conn_params_ = config_.symbolize_keys
|
67
|
-
|
68
|
-
conn_params_.delete_if { |_, v_| v_.nil? }
|
69
|
-
|
70
|
-
# Map ActiveRecords param names to PGs.
|
71
|
-
conn_params_[:user] = conn_params_.delete(:username) if conn_params_[:username]
|
72
|
-
conn_params_[:dbname] = conn_params_.delete(:database) if conn_params_[:database]
|
73
|
-
|
74
|
-
# Forward only valid config params to PGconn.connect.
|
75
|
-
conn_params_.keep_if { |k_, _| VALID_CONN_PARAMS.include?(k_) }
|
76
|
-
|
77
|
-
# The postgres drivers don't allow the creation of an unconnected PGconn object,
|
78
|
-
# so just pass a nil connection object for the time being.
|
79
|
-
::ActiveRecord::ConnectionAdapters::PostGISAdapter::MainAdapter.new(nil, logger, conn_params_, config_)
|
80
|
-
end
|
15
|
+
# Map ActiveRecords param names to PGs.
|
16
|
+
conn_params_[:user] = conn_params_.delete(:username) if conn_params_[:username]
|
17
|
+
conn_params_[:dbname] = conn_params_.delete(:database) if conn_params_[:database]
|
81
18
|
|
19
|
+
# Forward only valid config params to PGconn.connect.
|
20
|
+
conn_params_.keep_if { |k_, _| VALID_CONN_PARAMS.include?(k_) }
|
82
21
|
|
22
|
+
# The postgres drivers don't allow the creation of an unconnected PGconn object,
|
23
|
+
# so just pass a nil connection object for the time being.
|
24
|
+
::ActiveRecord::ConnectionAdapters::PostGISAdapter::MainAdapter.new(nil, logger, conn_params_, config_)
|
83
25
|
end
|
84
26
|
|
85
|
-
|
86
27
|
end
|
87
28
|
|
88
29
|
end
|
@@ -1,42 +1,5 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# PostGIS adapter for ActiveRecord
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010-2012 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
1
|
# :stopdoc:
|
38
2
|
|
39
|
-
|
40
3
|
namespace :db do
|
41
4
|
namespace :gis do
|
42
5
|
desc "Setup PostGIS data in the database"
|
@@ -51,5 +14,4 @@ namespace :db do
|
|
51
14
|
end
|
52
15
|
end
|
53
16
|
|
54
|
-
|
55
17
|
# :startdoc:
|
@@ -1,59 +1,15 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# PostGIS adapter for ActiveRecord
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010-2012 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
1
|
module ActiveRecord # :nodoc:
|
38
|
-
|
39
2
|
module ConnectionAdapters # :nodoc:
|
40
|
-
|
41
3
|
module PostGISAdapter # :nodoc:
|
42
|
-
|
43
|
-
|
44
4
|
class MainAdapter < PostgreSQLAdapter # :nodoc:
|
45
|
-
|
46
|
-
|
47
5
|
def initialize(*args_)
|
48
6
|
# Overridden to change the visitor
|
49
7
|
super
|
50
8
|
@visitor = ::Arel::Visitors::PostGIS.new(self)
|
51
9
|
end
|
52
10
|
|
53
|
-
|
54
11
|
include PostGISAdapter::CommonAdapterMethods
|
55
12
|
|
56
|
-
|
57
13
|
@@native_database_types = nil
|
58
14
|
|
59
15
|
def native_database_types
|
@@ -63,7 +19,6 @@ module ActiveRecord # :nodoc:
|
|
63
19
|
:geography => {:name => 'geography'})
|
64
20
|
end
|
65
21
|
|
66
|
-
|
67
22
|
def type_cast(value_, column_, array_member_=false)
|
68
23
|
if ::RGeo::Feature::Geometry.check_type(value_)
|
69
24
|
::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb, :emit_ewkb_srid => true).generate(value_)
|
@@ -72,22 +27,12 @@ module ActiveRecord # :nodoc:
|
|
72
27
|
end
|
73
28
|
end
|
74
29
|
|
75
|
-
|
76
30
|
def columns(table_name_, name_=nil)
|
77
31
|
# FULL REPLACEMENT. RE-CHECK ON NEW VERSIONS.
|
78
32
|
# We needed to return a spatial column subclass.
|
79
33
|
table_name_ = table_name_.to_s
|
80
34
|
spatial_info_ = spatial_column_info(table_name_)
|
81
35
|
column_definitions(table_name_).collect do |col_name_, type_, default_, notnull_, oid_, fmod_|
|
82
|
-
# JDBC support: JDBC adapter returns a hash for column definitions,
|
83
|
-
# instead of an array of values.
|
84
|
-
if col_name_.kind_of?(::Hash)
|
85
|
-
notnull_ = col_name_["column_not_null"]
|
86
|
-
default_ = col_name_["column_default"]
|
87
|
-
type_ = col_name_["column_type"]
|
88
|
-
col_name_ = col_name_["column_name"]
|
89
|
-
# TODO: get oid and fmod from jdbc
|
90
|
-
end
|
91
36
|
oid_ = OID::TYPE_MAP.fetch(oid_.to_i, fmod_.to_i) {
|
92
37
|
OID::Identity.new
|
93
38
|
}
|
@@ -96,7 +41,6 @@ module ActiveRecord # :nodoc:
|
|
96
41
|
end
|
97
42
|
end
|
98
43
|
|
99
|
-
|
100
44
|
def indexes(table_name_, name_=nil)
|
101
45
|
# FULL REPLACEMENT. RE-CHECK ON NEW VERSIONS.
|
102
46
|
result_ = query(<<-SQL, 'SCHEMA')
|
@@ -143,13 +87,11 @@ module ActiveRecord # :nodoc:
|
|
143
87
|
end.compact
|
144
88
|
end
|
145
89
|
|
146
|
-
|
147
90
|
def create_table_definition(name_, temporary_, options_)
|
148
91
|
# Override to create a spatial table definition (post-4.0.0.beta1)
|
149
92
|
PostGISAdapter::TableDefinition.new(native_database_types, name_, temporary_, options_, self)
|
150
93
|
end
|
151
94
|
|
152
|
-
|
153
95
|
def create_table(table_name_, options_={}, &block_)
|
154
96
|
table_name_ = table_name_.to_s
|
155
97
|
# Call super and snag the table definition
|
@@ -170,7 +112,6 @@ module ActiveRecord # :nodoc:
|
|
170
112
|
end
|
171
113
|
end
|
172
114
|
|
173
|
-
|
174
115
|
def drop_table(table_name_, *options_)
|
175
116
|
if postgis_lib_version.to_s.split('.').first.to_i == 1
|
176
117
|
execute("DELETE from geometry_columns where f_table_name='#{quote_string(table_name_.to_s)}'")
|
@@ -178,7 +119,6 @@ module ActiveRecord # :nodoc:
|
|
178
119
|
super
|
179
120
|
end
|
180
121
|
|
181
|
-
|
182
122
|
def add_column(table_name_, column_name_, type_, options_={})
|
183
123
|
table_name_ = table_name_.to_s
|
184
124
|
column_name_ = column_name_.to_s
|
@@ -214,7 +154,6 @@ module ActiveRecord # :nodoc:
|
|
214
154
|
end
|
215
155
|
end
|
216
156
|
|
217
|
-
|
218
157
|
def remove_column(table_name_, column_name_, type_=nil, options_={})
|
219
158
|
table_name_ = table_name_.to_s
|
220
159
|
column_name_ = column_name_.to_s
|
@@ -226,7 +165,6 @@ module ActiveRecord # :nodoc:
|
|
226
165
|
end
|
227
166
|
end
|
228
167
|
|
229
|
-
|
230
168
|
def add_index(table_name_, column_name_, options_={})
|
231
169
|
# FULL REPLACEMENT. RE-CHECK ON NEW VERSIONS.
|
232
170
|
# We have to fully-replace because of the gist_clause.
|
@@ -236,7 +174,6 @@ module ActiveRecord # :nodoc:
|
|
236
174
|
execute "CREATE #{index_type_} INDEX #{quote_column_name(index_name_)} ON #{quote_table_name(table_name_)}#{gist_clause_} (#{index_columns_})#{index_options_}"
|
237
175
|
end
|
238
176
|
|
239
|
-
|
240
177
|
def spatial_column_info(table_name_)
|
241
178
|
info_ = query("SELECT f_geometry_column,coord_dimension,srid,type FROM geometry_columns WHERE f_table_name='#{quote_string(table_name_.to_s)}'")
|
242
179
|
result_ = {}
|
@@ -259,12 +196,7 @@ module ActiveRecord # :nodoc:
|
|
259
196
|
result_
|
260
197
|
end
|
261
198
|
|
262
|
-
|
263
199
|
end
|
264
|
-
|
265
|
-
|
266
200
|
end
|
267
|
-
|
268
201
|
end
|
269
|
-
|
270
202
|
end
|