Sha256: 440371448c23f868a4e6058d4f75bf99dc0933caa0bfbd97c95b3a1ac3b44fa1

Contents?: true

Size: 788 Bytes

Versions: 16

Compression:

Stored size: 788 Bytes

Contents

require 'spec_helper'

RSpec.describe ROM::SQL::Schema, '#rename', :postgres, seeds: false do
  include_context 'users'

  before do
    conf.relation(:users) do
      schema(infer: true)
    end
  end

  it 'auto-projects a relation with renamed columns' do
    expect(relations[:users].schema.rename(id: :user_id, name: :user_name).(relations[:users]).dataset.sql)
      .to eql('SELECT "id" AS "user_id", "name" AS "user_name" FROM "users" ORDER BY "users"."id"')
  end

  it 'auto-projects a relation with renamed and qualified columns' do
    expect(relations[:users].schema.qualified.rename(id: :user_id, name: :user_name).(relations[:users]).dataset.sql)
      .to eql('SELECT "users"."id" AS "user_id", "users"."name" AS "user_name" FROM "users" ORDER BY "users"."id"')
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/integration/schema/rename_spec.rb
rom-sql-1.3.4 spec/integration/schema/rename_spec.rb
rom-sql-2.0.0.beta2 spec/integration/schema/rename_spec.rb
rom-sql-2.0.0.beta1 spec/integration/schema/rename_spec.rb
rom-sql-1.3.3 spec/integration/schema/rename_spec.rb
rom-sql-1.3.2 spec/integration/schema/rename_spec.rb
rom-sql-1.3.1 spec/integration/schema/rename_spec.rb
rom-sql-1.3.0 spec/integration/schema/rename_spec.rb
rom-sql-1.2.2 spec/integration/schema/rename_spec.rb
rom-sql-1.2.1 spec/integration/schema/rename_spec.rb
rom-sql-1.2.0 spec/integration/schema/rename_spec.rb
rom-sql-1.1.2 spec/integration/schema/rename_spec.rb
rom-sql-1.1.1 spec/integration/schema/rename_spec.rb
rom-sql-1.1.0 spec/integration/schema/rename_spec.rb
rom-sql-1.0.3 spec/integration/schema/rename_spec.rb
rom-sql-1.0.2 spec/integration/schema/rename_spec.rb