Class: ActiveRecord::ConnectionAdapters::Spanner::SchemaDumper
- Inherits:
-
ConnectionAdapters::SchemaDumper
- Object
- ConnectionAdapters::SchemaDumper
- ActiveRecord::ConnectionAdapters::Spanner::SchemaDumper
- Defined in:
- lib/active_record/connection_adapters/spanner/schema_dumper.rb
Overview
:nodoc:
Instance Method Summary collapse
- #default_primary_key?(column) ⇒ Boolean
- #header(stream) ⇒ Object
- #index_parts(index) ⇒ Object
- #prepare_column_options(column) ⇒ Object
- #trailer(stream) ⇒ Object
Instance Method Details
#default_primary_key?(column) ⇒ Boolean
13 14 15 |
# File 'lib/active_record/connection_adapters/spanner/schema_dumper.rb', line 13 def default_primary_key? column schema_type(column) == :integer end |
#header(stream) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/active_record/connection_adapters/spanner/schema_dumper.rb', line 35 def header stream str = StringIO.new super str stream.puts <<~HEADER #{str.string.rstrip} connection.start_batch_ddl HEADER end |
#index_parts(index) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/active_record/connection_adapters/spanner/schema_dumper.rb', line 55 def index_parts index index_parts = super index_parts << "null_filtered: #{index.null_filtered.inspect}" if index.null_filtered index_parts << "interleave_in: #{index.interleave_in.inspect}" if index.interleave_in index_parts << "storing: #{format_index_parts index.storing.sort}" if index.storing.present? index_parts end |
#prepare_column_options(column) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_record/connection_adapters/spanner/schema_dumper.rb', line 17 def column spec = super unless column...nil? spec[:allow_commit_timestamp] = column.. end if column.virtual? spec[:as] = extract_expression_for_virtual_column column spec[:stored] = true spec = { type: schema_type(column).inspect }.merge! spec end spec[:array] = true if column.sql_type.start_with? "ARRAY<" spec end |
#trailer(stream) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/active_record/connection_adapters/spanner/schema_dumper.rb', line 45 def trailer stream stream.puts <<~TRAILER connection.run_batch rescue abort_batch raise TRAILER super end |