File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
lib/arjdbc/postgresql/base Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,21 @@ def accessor
343343 end
344344 end
345345
346+ class Jsonb < Json
347+ def type
348+ :jsonb
349+ end
350+
351+ def changed_in_place? ( raw_old_value , new_value )
352+ # Postgres does not preserve insignificant whitespaces when
353+ # roundtripping jsonb columns. This causes some false positives for
354+ # the comparison here. Therefore, we need to parse and re-dump the
355+ # raw value here to ensure the insignificant whitespaces are
356+ # consistent with our encoder's output.
357+ raw_old_value = type_cast_for_database ( type_cast_from_database ( raw_old_value ) )
358+ super ( raw_old_value , new_value )
359+ end
360+ end if ActiveRecord ::VERSION . to_s >= '4.2'
346361 class Uuid < Type
347362 def type ; :uuid end
348363 def type_cast ( value )
You can’t perform that action at this time.
0 commit comments