Skip to content

Rails 7 fails with Enum columns #1042

@KDGundermann

Description

@KDGundermann

Issue

Migrating my old application to Rails 7 my tests fails on accessing the enum columns

Expected behavior

When accessing an enum column which is defined as:
enum orderstate: { open: "O", closed: "C" }
either order.open? or order.closed? should be truthy

Actual behavior

accessing an enum column always return false

How to reproduce

ActiveRecord Enum Test

class Datatypes < ActiveRecord::Base
  self.table_name = 'sst_datatypes'

  enum tinyint: { andromeda: 10 , bootes: 20 }
  enum char_10: { alpha: "A", beta: "B" }
end

class EnumTest < Minitest::Test
  def test_enum
    r = Datatypes.new

    r.andromeda!
    r.alpha!

    assert r.andromeda?
    refute r.bootes?

    assert r.alpha?
    refute r.beta?
  end
end

Details

  • Rails version: 7.0.4.2

  • Ruby version: 3.1.3

  • SQL Server adapter version: 7.0.0.0

  • TinyTDS version: 2.1.5

  • FreeTDS details:

    run `tsql -C` and paste here the output.
    
    Compile-time settings (established with the "configure" script)
                              Version: freetds v1.3.6
               freetds.conf directory: /usr/local/etc
       MS db-lib source compatibility: no
          Sybase binary compatibility: no
                        Thread safety: yes
                        iconv library: yes
                          TDS version: 7.4
                                iODBC: no
                             unixodbc: no
                SSPI "trusted" logins: no
                             Kerberos: no
                              OpenSSL: yes
                               GnuTLS: no
                                 MARS: yes
    
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions