Sha256: c9151ee159f36e484c5ec2fee9da25e199ee35b6b04aaee169733a7ffd54552c

Contents?: true

Size: 833 Bytes

Versions: 7

Compression:

Stored size: 833 Bytes

Contents

require 'spec_helper'

RSpec.describe ROM::SQL::Schema, '#rename' do
  include_context 'database setup'

  with_adapters :postgres do
    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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-sql-1.0.1 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0.rc2 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0.rc1 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0.beta3 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0.beta2 spec/integration/schema/rename_spec.rb
rom-sql-1.0.0.beta1 spec/integration/schema/rename_spec.rb