activerecord-cockroachdb-adapter icon indicating copy to clipboard operation
activerecord-cockroachdb-adapter copied to clipboard

Workaround timestamp precision issue

Open donbowman opened this issue 6 years ago • 0 comments

https://github.com/cockroachdb/cockroach/issues/32098 shows that Cockroachdb does not support timestamp precision (limit).

The most obvious workaround is to create the schema without a limit, e.g. remove the (#) from timestamp field on create table.

It would be nice to have the option in this adapter.

this code:

        def initialize_type_map(m = type_map)
          super(m)
          # NOTE(joey): PostgreSQL intervals have a precision.
          # CockroachDB intervals do not, so overide the type
          # definition. Returning a ArgumentError may not be correct.
          # This needs to be tested.
          m.register_type "interval" do |_, _, sql_type|
            precision = extract_precision(sql_type)
            if precision
              raise(ArgumentError, "CockroachDB does not support precision on intervals, but got precision: #{precision}")
            end
            OID::SpecializedString.new(:interval, precision: precision)
          end
        end

perhaps could be altered.

donbowman avatar Aug 29 '19 14:08 donbowman