Sha256: fe9ba27dbc177ab6e0c0adc9e0e86a7ad526a9b2c3ea46c5bd5aade3c910db86

Contents?: true

Size: 697 Bytes

Versions: 9

Compression:

Stored size: 697 Bytes

Contents

require 'spec_helper'

RSpec.describe ROM::SQL::Attribute, :postgres do
  include_context 'users and tasks'

  let(:users) { relations[:users] }
  let(:ds) { users.dataset }

  describe '#is' do
    it 'returns a boolean expression' do
      expect(users[:id].is(1).sql_literal(ds)).to eql('("id" = 1)')
    end

    it 'returns a boolean expression for qualified attribute' do
      expect((users[:id].qualified.is(1)).sql_literal(ds)).to eql('("users"."id" = 1)')
    end
  end

  describe '#concat' do
    it 'returns a concat function attribute' do
      expect(users[:id].concat(users[:name]).as(:uid).sql_literal(ds)).
        to eql(%(CONCAT("id", ' ', "name") AS "uid"))
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rom-sql-1.2.1 spec/unit/attribute_spec.rb
rom-sql-1.2.0 spec/unit/attribute_spec.rb
rom-sql-1.1.2 spec/unit/attribute_spec.rb
rom-sql-1.1.1 spec/unit/attribute_spec.rb
rom-sql-1.1.0 spec/unit/attribute_spec.rb
rom-sql-1.0.3 spec/unit/attribute_spec.rb
rom-sql-1.0.2 spec/unit/attribute_spec.rb
rom-sql-1.0.1 spec/unit/attribute_spec.rb
rom-sql-1.0.0 spec/unit/attribute_spec.rb