Sha256: c4f2893e06d5f870b79b5b4525b43a93036b6f653d46f07a24fe1dba6b034deb

Contents?: true

Size: 915 Bytes

Versions: 22

Compression:

Stored size: 915 Bytes

Contents

require_relative "spec_helper"

describe "constant_sql_override extension" do
  before do
    @db = Sequel.mock.extension(:constant_sql_override)
  end

  it 'overrides configured constants' do
    @db.set_constant_sql(Sequel::CURRENT_TIMESTAMP, "CURRENT TIMESTAMP AT TIME ZONE 'UTC'")
    @db[:tbl].where(foo: Sequel::CURRENT_TIMESTAMP).first
    @db.sqls.must_equal ["SELECT * FROM tbl WHERE (foo = CURRENT TIMESTAMP AT TIME ZONE 'UTC') LIMIT 1"]
  end

  it 'does not change behavior for unconfigured constants' do
    @db[:tbl].where(foo: Sequel::CURRENT_TIMESTAMP).first
    @db.sqls.must_equal ["SELECT * FROM tbl WHERE (foo = CURRENT_TIMESTAMP) LIMIT 1"]
  end

  it 'freezes the constant_sqls hash when frozen' do
    @db.freeze
    @db.constant_sqls.frozen?.must_equal true
    proc{@db.set_constant_sql(Sequel::CURRENT_TIMESTAMP, "CURRENT TIMESTAMP AT TIME ZONE 'UTC'")}.must_raise RuntimeError
  end
end

Version data entries

22 entries across 21 versions & 2 rubygems

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