Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:
end

def tablespace(table_name)
select_value(<<~SQL.squish, "SCHEMA")
select_value(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table_name.to_s.upcase)])
SELECT tablespace_name
FROM all_tables
WHERE table_name='#{table_name.to_s.upcase}'
WHERE table_name = :table_name
AND owner = SYS_CONTEXT('userenv', 'current_schema')
SQL
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def structure_dump_virtual_column(column, data_default) # :nodoc:

def structure_dump_primary_key(table) # :nodoc:
opts = { name: "", cols: [] }
pks = select_all(<<~SQL.squish, "SCHEMA")
pks = select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table.upcase)])
SELECT a.constraint_name, a.column_name, a.position
FROM all_cons_columns a
JOIN all_constraints c
ON a.constraint_name = c.constraint_name
WHERE c.table_name = '#{table.upcase}'
WHERE c.table_name = :table_name
AND c.constraint_type = 'P'
AND a.owner = c.owner
AND c.owner = SYS_CONTEXT('userenv', 'current_schema')
Expand All @@ -121,12 +121,12 @@ def structure_dump_primary_key(table) # :nodoc:

def structure_dump_unique_keys(table) # :nodoc:
keys = {}
uks = select_all(<<~SQL.squish, "SCHEMA")
uks = select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table.upcase)])
SELECT a.constraint_name, a.column_name, a.position
FROM all_cons_columns a
JOIN all_constraints c
ON a.constraint_name = c.constraint_name
WHERE c.table_name = '#{table.upcase}'
WHERE c.table_name = :table_name
AND c.constraint_type = 'U'
AND a.owner = c.owner
AND c.owner = SYS_CONTEXT('userenv', 'current_schema')
Expand Down Expand Up @@ -385,9 +385,9 @@ def drop_sql_for_feature(type)
end

def drop_sql_for_object(type)
objects = select_values(<<~SQL.squish, "SCHEMA")
objects = select_values(<<~SQL.squish, "SCHEMA", [bind_string("object_type", type.upcase)])
SELECT object_name FROM all_objects
WHERE object_type = '#{type.upcase}' and owner = SYS_CONTEXT('userenv', 'current_schema')
WHERE object_type = :object_type and owner = SYS_CONTEXT('userenv', 'current_schema')
SQL
statements = objects.map do |name|
"DROP #{type.upcase} \"#{name}\""
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def dump_table_schema(table, connection = ActiveRecord::Base.lease_connection)
host: DATABASE_HOST,
port: DATABASE_PORT,
username: DATABASE_USER,
password: DATABASE_PASSWORD
password: DATABASE_PASSWORD,
prepared_statements: false
}

CONNECTION_PARAMS_WITH_PREPARED_STATEMENTS = CONNECTION_PARAMS.merge(prepared_statements: true)
Expand Down
Loading