# File lib/big_query_adapter/schema_statements.rb, line 50 def primary_key(_table_name) [] end
module BigQueryAdapter::SchemaStatements
Includes helper methods
Public Instance Methods
columns(table_name, _name = nil)
click to toggle source
Returns an array of Column objects for the table specified by table_name
. rubocop:disable Metrics/MethodLength, Metrics/AbcSize
# File lib/big_query_adapter/schema_statements.rb, line 23 def columns(table_name, _name = nil) result = @connection.columns(table_name.to_s) result.each_with_object([]) do |field, cols| col_name = field.name col_sql_type = native_database_types.invert[name: field.type] col_nullable = (field.mode == 'NULLABLE') args = { sql_type: col_sql_type, type: col_sql_type, limit: nil } args[:scale] = nil args[:precision] = nil sql_type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(**args) cols << ActiveRecord::ConnectionAdapters::Column.new( col_name, nil, sql_type_metadata, col_nullable, table_name ) end end
current_database()
click to toggle source
# File lib/big_query_adapter/schema_statements.rb, line 65 def current_database database_metadata.database_name.strip end
foreign_keys(_table_name)
click to toggle source
# File lib/big_query_adapter/schema_statements.rb, line 54 def foreign_keys(_table_name) [] end
index_name(table_name, options)
click to toggle source
Ensure it's shorter than the maximum identifier length for the current dbms
Calls superclass method
# File lib/big_query_adapter/schema_statements.rb, line 60 def index_name(table_name, options) maximum = database_metadata.max_identifier_len || 255 super(table_name, options)[0...maximum] end
indexes(_table_name, _name = nil)
click to toggle source
Returns an array of indexes for the given table.
# File lib/big_query_adapter/schema_statements.rb, line 16 def indexes(_table_name, _name = nil) [] end
primary_key(_table_name)
click to toggle source
Returns just a table's primary key
tables(_name = nil)
click to toggle source
Returns an array of table names, for database tables visible on the current connection.
# File lib/big_query_adapter/schema_statements.rb, line 6 def tables(_name = nil) raw_connection.tables end
views()
click to toggle source
Returns an array of view names defined in the database.
# File lib/big_query_adapter/schema_statements.rb, line 11 def views [] end