| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Don't use column object for type casting in `quoting`
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We're never going to be able to use the attribute object here, however,
so let's just accept the ugly demeter violation here for now.
Remove test cases which were either redundant with other tests in the
file, or were actually testing the type objects (which are tested
elsewhere)
|
|/ |
|
|\
| |
| | |
Don't type cast the default on the column
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
Also takes a step towards supporting types which use a character other
than ',' for the delimiter (`box` is the only built in type for which
this is the case)
|
|\ \
| |/
|/| |
Move pg array database type casting to the Array type
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The case where we have a column object, but don't have a type cast
method involves type casting the default value when changing the schema.
We get one of the column definition structs instead. That is a case that
I'm trying to remove overall, but in the short term, we can achieve the
same behavior without needing to pass the adapter to the array type by
creating a fake type that proxies to the adapter.
|
|/
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
Fixes #15705.
|
| |
|
|\
| |
| | |
Detect in-place changes on mutable AR attributes
|
| |
| |
| |
| |
| |
| | |
We have several mutable types on Active Record now. (Serialized, JSON,
HStore). We need to be able to detect if these have been modified in
place.
|
|\ \
| | |
| | | |
Introduce an Attribute object to handle the type casting dance
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
There's a lot more that can be moved to these, but this felt like a good
place to introduce the object. Plans are:
- Remove all knowledge of type casting from the columns, beyond a
reference to the cast_type
- Move type_cast_for_database to these objects
- Potentially make them mutable, introduce a state machine, and have
dirty checking handled here as well
- Move `attribute`, `decorate_attribute`, and anything else that
modifies types to mess with this object, not the columns hash
- Introduce a collection object to manage these, reduce allocations, and
not require serializing the types
|
| |/
|/|
| |
| |
| |
| | |
We guarantee that `model.value` does not change after
`model.save && model.reload`. This requires type casting user input for
non-string types.
|
|/
|
|
| |
We're not longer using `ipaddr` in schema dumper
|
|
|
|
|
| |
We are no longer including column objects in YAML serialization, thanks
to https://github.com/rails/rails/pull/15621
|
|
|
|
|
| |
On MySQL and PostgreSQL, the adapter does not type cast virtual columns
for us.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|\
| |
| | |
Don't query the database schema when calling `serialize`
|
| |
| |
| |
| |
| |
| | |
We need to decorate the types lazily. This is extracted to a separate
API, as there are other refactorings that will be able to make use of
it, and to allow unit testing the finer points more granularly.
|
|/ |
|
|\
| |
| | |
Bring type casting behavior of hstore/json in line with serialized
|
| |
| |
| |
| |
| | |
`@raw_attributes` should not contain the type-cast, mutable version of
the value.
|
| |
| |
| |
| | |
Whiny nils is no longer a thing, so we no longer need this optimization
|
| |
| |
| |
| | |
BC era year is (astronomical year + 1) and starts from 1 BC.
|
| |
| |
| |
| |
| |
| | |
Follow up to #15438 and #15502.
/cc @sgrif
|
|/
|
|
|
|
|
| |
For any type that is represented as a string and then type cast, we do
not need separate regular expressions for the various types. No function
will match this regex. User defined types *should* match this, so that
the type object can decide what to do with the value.
|
|
|
|
| |
skip]
|
|\
| |
| | |
Keep column defaults in type cast form
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The contract of `_field_changed?` assumes that the old value is always
type cast. That is not the case for the value in `Column#default` as
things are today. It appears there are other public methods that
assume that `Column#default` is type cast, as well. The reason for this
change originally was because the value gets put into `@raw_attributes`
in initialize. This reverts to the old behavior on `Column`, and updates
`initialize` to make sure that the values are in the right format.
|
|\ \
| | |
| | | |
Refactor quoting of binary data to not be based on the column type
|
| |/ |
|
| | |
|
|\ \
| | |
| | | |
Respect limit for PG bit strings
|
| | | |
|
|\ \ \
| |/ /
|/| | |
Refactor determination of whether the field has changed
|
| |/
| |
| |
| |
| | |
The types know more about what is going on than the dirty module. Let's
ask them!
|
|/ |
|
| |
|
|
|
|
|
|
|
|
| |
This inlines casting for the most obvious types. The rest will
follow eventually. I need to put some tests in place, to make sure
that the inlining is not causing regressions.
/cc @sgrif
|
|
|
|
|
|
|
|
|
|
|
| |
Nearly completely implemented in terms of custom properties.
`_before_type_cast` now stores the raw serialized string consistently,
which removes the need to keep track of "state". The following is now
consistently true:
- `model.serialized == model.reload.serialized`
- A model can be dumped and loaded infinitely without changing
- A model can be saved and reloaded infinitely without changing
|
|
|
|
|
|
|
| |
This removes the case statement in `SchemaDumper` and gives every `Type`
the possibility to control the SchemaDumper default value output.
/cc @sgrif
|
|
|
|
|
| |
This is an intermediate solution. It is related to the refactoring @sgrif
is making and will change in the future.
|