Sha256: 641078554c49e26ec8297c0213e071303fedfd8dea676ce69ea9f16a3c88d20f
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' RSpec.describe ROM::SQL::OrderDSL, :postgres, helpers: true do include_context 'database setup' subject(:dsl) do ROM::SQL::OrderDSL.new(schema) end let(:schema) do define_schema(:users, id: ROM::SQL::Types::Serial, name: ROM::SQL::Types::String) end let(:ds) do conn[:users] end describe '#call' do it 'returns an array with ordered expressions' do expect(ds.literal(dsl.call { id }.first)).to eql('"id"') end end describe '#method_missing' do it 'responds to methods matching attribute names' do expect(dsl.id.name).to be(:id) expect(dsl.name.name).to be(:name) end it 'delegates to sequel virtual row' do expect(ds.literal(dsl.call { nullif(id.qualified, Sequel.lit("''")).desc }.first)). to eql(%(NULLIF("users"."id", '') DESC)) end it 'allows to set nulls first/last' do expect(ds.literal(dsl.call { id.desc(nulls: :first) }.first)). to eql(%("id" DESC NULLS FIRST)) expect(ds.literal(dsl.call { id.desc(nulls: :last) }.first)). to eql(%("id" DESC NULLS LAST)) end end end
Version data entries
6 entries across 6 versions & 1 rubygems