Skip to content
  • Ryuta Kamizono's avatar
    19839ff4
    Fix string type cast with boolean serialization for MySQL · 19839ff4
    Ryuta Kamizono authored
    And benchmark with this branch for immutable string type:
    
    ```ruby
    ActiveRecord::Schema.define do
      create_table :users, force: true do |t|
        t.string :name
        t.string :fast_name
      end
    end
    
    class User < ActiveRecord::Base
      attribute :fast_name, :immutable_string
    end
    
    user = User.new
    
    Benchmark.ips do |x|
      x.report("user.name") do
        user.name = "foo"
        user.name_changed?
      end
      x.report("user.fast_name") do
        user.fast_name = "foo"
        user.fast_name_changed?
      end
    end
    ```
    
    ```
    Warming up --------------------------------------
               user.name    34.811k i/100ms
          user.fast_name    39.505k i/100ms
    Calculating -------------------------------------
               user.name    343.864k (± 3.6%) i/s -      1.741M in   5.068576s
          user.fast_name    384.033k (± 2.7%) i/s -      1.936M in   5.044425s
    ```
    19839ff4
    Fix string type cast with boolean serialization for MySQL
    Ryuta Kamizono authored
    And benchmark with this branch for immutable string type:
    
    ```ruby
    ActiveRecord::Schema.define do
      create_table :users, force: true do |t|
        t.string :name
        t.string :fast_name
      end
    end
    
    class User < ActiveRecord::Base
      attribute :fast_name, :immutable_string
    end
    
    user = User.new
    
    Benchmark.ips do |x|
      x.report("user.name") do
        user.name = "foo"
        user.name_changed?
      end
      x.report("user.fast_name") do
        user.fast_name = "foo"
        user.fast_name_changed?
      end
    end
    ```
    
    ```
    Warming up --------------------------------------
               user.name    34.811k i/100ms
          user.fast_name    39.505k i/100ms
    Calculating -------------------------------------
               user.name    343.864k (± 3.6%) i/s -      1.741M in   5.068576s
          user.fast_name    384.033k (± 2.7%) i/s -      1.936M in   5.044425s
    ```
Loading