Sha256: 30c03a85095ea42608997f0e484d106a72599748c7080226d6a60194f2cabaf3

Contents?: true

Size: 1 KB

Versions: 45

Compression:

Stored size: 1 KB

Contents

require_relative "spec_helper"

describe "pg_loose_count extension" do
  before do
    @db = Sequel.mock(:host=>'postgres', :fetch=>{:v=>1}).extension(:pg_loose_count)
    @db.extend_datasets{def quote_identifiers?; false end}
  end

  it "should add loose_count method getting fast count for entire table using table statistics" do
    @db.loose_count(:a).must_equal 1
    @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a' AS regclass) AS oid)) LIMIT 1"]
  end

  it "should support schema qualified tables" do
    @db.loose_count(Sequel[:a][:b]).must_equal 1
    @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a.b' AS regclass) AS oid)) LIMIT 1"]
  end

  with_symbol_splitting "should support schema qualified table symbols" do
    @db.loose_count(:a__b).must_equal 1
    @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a.b' AS regclass) AS oid)) LIMIT 1"]
  end
end

Version data entries

45 entries across 41 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/pg_loose_count_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/pg_loose_count_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.29.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.28.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.27.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.26.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.25.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.24.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.23.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.22.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.21.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.20.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.13 vendor/bundle/gems/sequel-5.18.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.19.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.12.1 vendor/bundle/gems/sequel-5.18.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.18.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.17.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.16.0 spec/extensions/pg_loose_count_spec.rb