Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum name query doesn't work with char type #2383

Open
yusiro-bps opened this issue May 28, 2024 · 0 comments
Open

Enum name query doesn't work with char type #2383

yusiro-bps opened this issue May 28, 2024 · 0 comments

Comments

@yusiro-bps
Copy link

Steps to reproduce

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "activerecord", github: "rails/rails", branch: "7-0-stable"
  gem "activerecord-oracle_enhanced-adapter",  github: "rsim/oracle-enhanced", branch: "release70"
  gem "minitest"

  platforms :ruby do
    gem "ruby-oci8", github: "kubo/ruby-oci8"
  end
end

require "active_record"
require "minitest/autorun"
require "logger"
require "active_record/connection_adapters/oracle_enhanced_adapter"

# Set Oracle enhanced adapter specific connection parameters
DATABASE_NAME = ENV["DATABASE_NAME"] || "orcl"
DATABASE_HOST = ENV["DATABASE_HOST"]
DATABASE_PORT = ENV["DATABASE_PORT"]
DATABASE_USER = ENV["DATABASE_USER"] || "oracle_enhanced"
DATABASE_PASSWORD = ENV["DATABASE_PASSWORD"] || "oracle_enhanced"
DATABASE_SYS_PASSWORD = ENV["DATABASE_SYS_PASSWORD"] || "admin"

CONNECTION_PARAMS = {
  adapter: "oracle_enhanced",
  database: DATABASE_NAME,
  host: DATABASE_HOST,
  port: DATABASE_PORT,
  username: DATABASE_USER,
  password: DATABASE_PASSWORD
}

ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)

ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
  create_table :posts, force: true, id: false do |t|
    t.column :status, 'char(1)'
  end
end

class Post < ActiveRecord::Base
  enum status: { active: '0', archived: '1' }
end

class BugTest < Minitest::Test
  def test_association_stuff
    post = Post.create!(status: :archived)
    assert_equal 'archived', post.status
    assert post.archived?
  end
end

Expected behavior

post#archived? returns true

Actual behavior

post#archived? returns false

  1) Failure:
BugTest#test_association_stuff [active_record_gem.rb:59]:
Expected false to be truthy.

1 runs, 2 assertions, 1 failures, 0 errors, 0 skips

System configuration

Rails version: 7.0.8

Oracle enhanced adapter version: 7.0.3

Ruby version: 3.1.3

Oracle Database version: Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant