1. 26 6月, 2014 1 次提交
    • S
      Consolidate testing of update_all type casting · 58d38d6d
      Sean Griffin 提交于
      We have several test cases on "tricky" types that are essentially
      testing that `update_all` goes through the same type casting behavior as
      a normal assignment + save. We recently had another case to add this
      test for another type in https://github.com/rails/rails/pull/12742.
      
      Rather than testing this separately for every type which is "tricky"
      when round tripping, let's instead have a fairly exhaustive test that
      ensures we're getting the correct values at every step for `update_all`.
      Given the structure of the code now, we can be confident that if the
      type is correct, and `update_all` is type casting correctly, we're going
      to get the right behavior for all types.
      58d38d6d
  2. 18 6月, 2014 2 次提交
    • S
      Don't type cast the default on the column · 4d3e88fc
      Sean Griffin 提交于
      If we want to have type decorators mess with the attribute, but not the
      column, we need to stop type casting on the column. Where possible, we
      changed the tests to test the value of `column_defaults`, which is
      public API. `Column#default` is not.
      4d3e88fc
    • S
      Don't assume that Hstore columns have always changed · d9812729
      Sean Griffin 提交于
      HStore columns come back from the database separated by a comma and a
      space, not just a comma. We need to mirror that behavior since we
      compare the two values.
      
      Also adds a regression test against JSON to ensure we don't have the
      same bug there.
      d9812729
  3. 14 6月, 2014 1 次提交
  4. 10 6月, 2014 2 次提交
    • S
      Rename `type_cast` to `type_cast_from_database` · d24e6407
      Sean Griffin 提交于
      In some cases there is a difference between the two, we should always
      be doing one or the other. For convenience, `type_cast` is still a
      private method on type, so new types that do not need different behavior
      don't need to implement two methods, but it has been moved to private so
      it cannot be used accidentally.
      d24e6407
    • S
      Make `_before_type_cast` actually be before type cast · c93dbfef
      Sean Griffin 提交于
      - The following is now true for all types, all the time
        - `model.attribute_before_type_cast == given_value`
        - `model.attribute == model.save_and_reload.attribute`
        - `model.attribute == model.dup.attribute`
        - `model.attribute == YAML.load(YAML.dump(model)).attribute`
      - Removes the remaining types implementing `type_cast_for_write`
      - Simplifies the implementation of time zone aware attributes
      - Brings tz aware attributes closer to being implemented as an attribute
        decorator
      - Adds additional point of control for custom types
      c93dbfef
  5. 09 6月, 2014 1 次提交
  6. 06 6月, 2014 1 次提交
  7. 04 6月, 2014 2 次提交
  8. 03 6月, 2014 2 次提交
  9. 28 5月, 2014 1 次提交
    • Y
      pg, keep `hstore` and `json` attributes as `Hash` in @attributes. · bdbf00dc
      Yves Senn 提交于
      The solution presented in this patch is not efficient. We should replace it
      in the near future. The following needs to be worked out:
        * Is `@attributes` storing the Ruby or SQL representation?
        * `cacheable_column?` is broken but `hstore` and `json` rely on that behavior
      
      Refs #15369.
      
      /cc @sgrif @rafaelfranca
      bdbf00dc
  10. 12 5月, 2014 1 次提交
  11. 28 3月, 2014 2 次提交
  12. 15 3月, 2014 1 次提交
  13. 17 2月, 2014 1 次提交
    • J
      Resolve encoding issues with arrays of hstore (bug 11135). · da3fec2e
      Josh Goodall 提交于
      We didn't have enough encoding for the wire protocol to store an array
      of hstore types. So, further encode any hstore that is an array member.
      Whilst we're here, ensure it's an HashWithIndifferentAccess being
      returned, to be consistent with other serialized forms, and add testing
      for arrays of hstore.
      
      So now the following migration:
      
        enable_extension "hstore"
        create_table :servers do |t|
          t.string  :name
          t.hstore  :interfaces, array: true
        end
      
      produces a model that can used like this, to store an array of hashes:
      
        server = Server.create(name: "server01", interfaces: [
          { name: "bge0", ipv4: "192.0.2.2", state: "up" },
          { name: "de0", state: "disabled", by: "misha" },
          { name: "fe0", state: "up" },
        ])
      
      More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/
      da3fec2e
  14. 07 1月, 2014 1 次提交
    • N
      Make change_table use object of current database adapter · eb589fed
      Nishant Modak 提交于
        - Earlier, change_table was creating database-agnostic object.
        - After this change, it will create correct object based on current
          database adapter.
        - This will ensure that create_table and change_table will get same objects.
        - This makes update_table_definition method public and nodoc.
        - Fixes #13577 and #13503
      eb589fed
  15. 24 12月, 2013 2 次提交
  16. 08 11月, 2013 1 次提交
  17. 25 10月, 2013 1 次提交
  18. 08 8月, 2013 1 次提交
  19. 27 3月, 2013 1 次提交
  20. 24 3月, 2013 1 次提交
  21. 28 2月, 2013 1 次提交
  22. 07 2月, 2013 2 次提交
  23. 06 2月, 2013 1 次提交
  24. 29 1月, 2013 1 次提交
  25. 27 4月, 2012 1 次提交
  26. 25 4月, 2012 1 次提交
    • R
      Always quote hstore keys and values · 0c46dbbc
      Ryan Fitzgerald 提交于
      escape_hstore uses quotation marks around keys and values only if it
      seems necessary. However, it currently breaks in the presence of some
      non-ASCII characters. Instead of trying to guess exactly which
      characters are safe, it seems better to always use quotes.
      0c46dbbc
  27. 09 2月, 2012 3 次提交
  28. 21 12月, 2011 4 次提交