Class: ActiveRecord::ConnectionAdapters::CockroachDB::Column
- Inherits:
-
PostgreSQL::Column
- Object
- PostgreSQL::Column
- ActiveRecord::ConnectionAdapters::CockroachDB::Column
- Defined in:
- lib/active_record/connection_adapters/cockroachdb/column.rb
Instance Attribute Summary collapse
-
#geographic ⇒ Object
(also: #geographic?)
readonly
Returns the value of attribute geographic.
-
#geometric_type ⇒ Object
readonly
Returns the value of attribute geometric_type.
-
#has_m ⇒ Object
(also: #has_m?)
readonly
Returns the value of attribute has_m.
-
#has_z ⇒ Object
(also: #has_z?)
readonly
Returns the value of attribute has_z.
-
#srid ⇒ Object
readonly
Returns the value of attribute srid.
Instance Method Summary collapse
- #hidden? ⇒ Boolean
-
#initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil, identity: nil, serial: nil, spatial: nil, generated: nil, hidden: nil) ⇒ Column
constructor
most functions taken from activerecord-postgis-adapter spatial_column github.com/rgeo/activerecord-postgis-adapter/blob/master/lib/active_record/connection_adapters/postgis/spatial_column.rb.
- #limit ⇒ Object
- #serial? ⇒ Boolean
- #spatial? ⇒ Boolean
Constructor Details
#initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil, identity: nil, serial: nil, spatial: nil, generated: nil, hidden: nil) ⇒ Column
most functions taken from activerecord-postgis-adapter spatial_column github.com/rgeo/activerecord-postgis-adapter/blob/master/lib/active_record/connection_adapters/postgis/spatial_column.rb
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 23 def initialize(name, default, = nil, null = true, default_function = nil, collation: nil, comment: nil, identity: nil, serial: nil, spatial: nil, generated: nil, hidden: nil) @sql_type_metadata = @geographic = !!(.sql_type =~ /geography\(/i) @hidden = hidden if spatial # This case comes from an entry in the geometry_columns table set_geometric_type_from_name(spatial[:type]) @srid = spatial[:srid].to_i @has_z = !!spatial[:has_z] @has_m = !!spatial[:has_m] elsif @geographic # Geographic type information is embedded in the SQL type @srid = 4326 @has_z = @has_m = false build_from_sql_type(.sql_type) elsif sql_type =~ /geography|geometry|point|linestring|polygon/i build_from_sql_type(.sql_type) elsif .sql_type =~ /geography|geometry|point|linestring|polygon/i # A geometry column with no geometry_columns entry. # @geometric_type = geo_type_from_sql_type(sql_type) build_from_sql_type(.sql_type) end super(name, default, , null, default_function, collation: collation, comment: comment, serial: serial, generated: generated, identity: identity) if spatial? && @srid @limit = { srid: @srid, type: to_type_name(geometric_type) } @limit[:has_z] = true if @has_z @limit[:has_m] = true if @has_m @limit[:geographic] = true if @geographic end end |
Instance Attribute Details
#geographic ⇒ Object (readonly) Also known as: geographic?
Returns the value of attribute geographic.
58 59 60 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 58 def geographic @geographic end |
#geometric_type ⇒ Object (readonly)
Returns the value of attribute geometric_type.
58 59 60 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 58 def geometric_type @geometric_type end |
#has_m ⇒ Object (readonly) Also known as: has_m?
Returns the value of attribute has_m.
58 59 60 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 58 def has_m @has_m end |
#has_z ⇒ Object (readonly) Also known as: has_z?
Returns the value of attribute has_z.
58 59 60 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 58 def has_z @has_z end |
#srid ⇒ Object (readonly)
Returns the value of attribute srid.
58 59 60 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 58 def srid @srid end |
Instance Method Details
#hidden? ⇒ Boolean
72 73 74 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 72 def hidden? @hidden end |
#limit ⇒ Object
68 69 70 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 68 def limit spatial? ? @limit : super end |
#serial? ⇒ Boolean
80 81 82 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 80 def serial? default_function == 'unique_rowid()' end |
#spatial? ⇒ Boolean
76 77 78 |
# File 'lib/active_record/connection_adapters/cockroachdb/column.rb', line 76 def spatial? %i[geometry geography].include?(@sql_type_metadata.type) end |