mini_record icon indicating copy to clipboard operation
mini_record copied to clipboard

Problems with SQLite

Open Xanders opened this issue 11 years ago • 2 comments

Hello! MiniRecord is awesome, especially with MySQL. While using with SQLite I have some problems with it:

  • When I use decimal columns, everytime I call auto_upgrade! it re-create tables. My English is terrible, so let me show example:
class Some < ActiveRecord::Base
  field :one, :two, :three, as: :decimal, scale: 2
end
...
Some.auto_upgrade! # happyness
Some.auto_upgrade! # oh:
# [MiniRecord] Detected schema change for somes.one#scale from nil to 2
# [MiniRecord] Changing column somes.one to new type decimal
# re-creating table with tempolary table for each column
Some.auto_upgrade! # and again...
  • [critical] While creating tempolaty tables on re-creating there are exceptions on binary fields (there was MessagePack objects in my case):
SQLite3::SQLException: unrecognized token: "<binary_data_here>": INSERT INTO "altered_somes" ...

So, changing fields with MiniRecord is impossible with any binary data in table.

  • When using MySQL there is a warning:
Error adding decimal column: precision cannot be empty if scale if specified

But when using SQLite there is no any warnings. And in AR's migrations there is no such warning too.

Of cource, all of that are not End of the World, because I can use MySQL instead, but maybe it will usefull information for you. :)

Xanders avatar Nov 25 '14 16:11 Xanders

I think (not sure) that sqlite doesn't support decimals or decimals with precision. Check the docs.

DAddYE avatar Nov 25 '14 18:11 DAddYE

Maybe it's true: http://stackoverflow.com/questions/21757722/how-to-use-sqlite-decimal-precision-notation

But if it is, MiniRecord should ignore scale/precision changes on SQLite? Because otherwise re-creating tables (which is not good, but not critical) with binary data cause second problem (critical), at fact MiniRecord don't work in this case (and in any case which cause table re-creating).

Xanders avatar Nov 25 '14 19:11 Xanders