Skip to content

Conversation

@aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Apr 14, 2021

Fixed the "bit" type column error NoMethodError: undefined method '-@' for true:TrueClass.

Issue was that the default value for a column in the SQL Server adapter can be true/false. However, the true/false classes do not implement the '-@' method to return a frozen version of the value. However, since true/false are already frozen there is no need to call the -@ method anyway.

irb(main):0> 'test'.frozen?
=> false

irb(main):0> (-'test').frozen?
=> true

irb(main):0> -false
NoMethodError (undefined method `-@' for false:FalseClass)

irb(main):0> -true
NoMethodError (undefined method `-@' for true:TrueClass)

irb(main):0> false.frozen?
=> true

irb(main):0> true.frozen?
=> true

Tests Before
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/runs/2342106156
7133 runs, 8923 assertions, 36 failures, 3373 errors, 33 skips

Tests After
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/875/checks?check_run_id=2342446944
7133 runs, 14121 assertions, 38 failures, 1590 errors, 37 skips

@aidanharan aidanharan marked this pull request as ready for review April 14, 2021 12:45
@aidanharan aidanharan force-pushed the deduplicate-boolean-fix branch from 46d128f to 02da428 Compare April 14, 2021 13:09
@wpolicarpo wpolicarpo merged commit 2fbded9 into rails-sqlserver:main Apr 14, 2021
lavika pushed a commit to lavika/activerecord-sqlserver-adapter that referenced this pull request Sep 26, 2023
…ver#875)

Co-authored-by: Aidan Haran <aharan@fusioneer.com>
Co-authored-by: Wanderson Policarpo <wpolicarpo@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants