Class: ActiveRecord::ConnectionAdapters::CockroachDB::SpatialColumnInfo
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::CockroachDB::SpatialColumnInfo
- Defined in:
- lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb
Instance Method Summary collapse
- #all ⇒ Object
-
#get(column_name, type) ⇒ Object
do not query the database for non-spatial columns/tables.
-
#initialize(adapter, table_name) ⇒ SpatialColumnInfo
constructor
A new instance of SpatialColumnInfo.
Constructor Details
#initialize(adapter, table_name) ⇒ SpatialColumnInfo
Returns a new instance of SpatialColumnInfo.
21 22 23 24 |
# File 'lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb', line 21 def initialize(adapter, table_name) @adapter = adapter @table_name = table_name end |
Instance Method Details
#all ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb', line 26 def all info = @adapter.query( "SELECT f_geometry_column,coord_dimension,srid,type FROM geometry_columns WHERE f_table_name='#{@table_name}'" ) result = {} info.each do |row| name = row[0] type = row[3] dimension = row[1].to_i has_m = !!(type =~ /m$/i) type.sub!(/m$/, '') has_z = dimension > 3 || dimension == 3 && !has_m result[name] = { dimension: dimension, has_m: has_m, has_z: has_z, name: name, srid: row[2].to_i, type: type } end result end |
#get(column_name, type) ⇒ Object
do not query the database for non-spatial columns/tables
51 52 53 54 55 56 |
# File 'lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb', line 51 def get(column_name, type) return unless CockroachDBAdapter.(type.to_sym) @spatial_column_info ||= all @spatial_column_info[column_name] end |