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.0.11 vendor/bundle/gems/sequel-5.11.0/spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.11 vendor/bundle/gems/sequel-5.15.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.15.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.14.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.13.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.12.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.11.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.10.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.9 vendor/bundle/gems/sequel-5.9.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.9.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.8.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.7.1 spec/extensions/pg_loose_count_spec.rb
sequel-5.7.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/sequel-5.3.0/spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.8 vendor/bundle/gems/sequel-5.6.0/spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/sequel-5.6.0/spec/extensions/pg_loose_count_spec.rb
sequel-5.6.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.5.0 spec/extensions/pg_loose_count_spec.rb
sequel-5.4.0 spec/extensions/pg_loose_count_spec.rb
tdiary-5.0.7 vendor/bundle/gems/sequel-5.3.0/spec/extensions/pg_loose_count_spec.rb