SQLite/Rails/Human bug? "SQL logic error"

Hi,

I’ve searched with no end for any clue as to why I get the following
error:

SQLite3::SQLException: SQL logic error or missing database: INSERT INTO
estudio_stages (“updated_at”, “estudio_id”, “created_at”, “stage_id”)
VALUES(‘2007-07-23 16:32:42’, 2, ‘2007-07-23 16:32:42’, 4)

…when accesing a certain action in a controller… but if I execute
that SQL code directly in sqlite, or call the appropiate method in my
model from the console, it works!

So what gives?

Thanks for any help!

  • Ivan V.

Ivan V. wrote:

Hi,

I’ve searched with no end for any clue as to why I get the following
error:

SQLite3::SQLException: SQL logic error or missing database: INSERT INTO
estudio_stages (“updated_at”, “estudio_id”, “created_at”, “stage_id”)
VALUES(‘2007-07-23 16:32:42’, 2, ‘2007-07-23 16:32:42’, 4)

…when accesing a certain action in a controller… but if I execute
that SQL code directly in sqlite, or call the appropiate method in my
model from the console, it works!

So what gives?

Thanks for any help!

  • Ivan V.

For a second there I thought I had a clue… Here’s part of the trace:

vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:135:in
log' vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:inexecute’
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:341:in
catch_schema_changes' vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:inexecute’
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:147:in
`insert’

So there’s a method named ‘catch_schema_changes’ in the sqlite adapter,
and I read somewhere that SQLite doesn’t support renaming columns, so I
thought if I deleted and then re-created the schema.rb file then it
might just work (don’t ask me the logic behind such reasoning), but it
doesn’t…

Ivan V. wrote:

Hi,

I’ve searched with no end for any clue as to why I get the following
error:

SQLite3::SQLException: SQL logic error or missing database: INSERT INTO
estudio_stages (“updated_at”, “estudio_id”, “created_at”, “stage_id”)
VALUES(‘2007-07-23 16:32:42’, 2, ‘2007-07-23 16:32:42’, 4)

…when accesing a certain action in a controller… but if I execute
that SQL code directly in sqlite, or call the appropiate method in my
model from the console, it works!

So what gives?

Thanks for any help!

  • Ivan V.

This just gets weirder… If I debug the application with NetBeans and
set a breakpoint on the AR object’s save method to try and see where the
problem might be, I step into a few statements, then NetBeans seem to
not want to step any further, so I press “Continue” to finish the
remaining calls… and then it works…, with no error thrown…

Just now I also tried executing directly with
AR::Base.connection.execute… no luck :frowning:

Ivan V. wrote:

Ivan V. wrote:

Hi,

I’ve searched with no end for any clue as to why I get the following
error:

SQLite3::SQLException: SQL logic error or missing database: INSERT INTO
estudio_stages (“updated_at”, “estudio_id”, “created_at”, “stage_id”)
VALUES(‘2007-07-23 16:32:42’, 2, ‘2007-07-23 16:32:42’, 4)

…when accesing a certain action in a controller… but if I execute
that SQL code directly in sqlite, or call the appropiate method in my
model from the console, it works!

So what gives?

Thanks for any help!

  • Ivan V.

This just gets weirder… If I debug the application with NetBeans and
set a breakpoint on the AR object’s save method to try and see where the
problem might be, I step into a few statements, then NetBeans seem to
not want to step any further, so I press “Continue” to finish the
remaining calls… and then it works…, with no error thrown…

Just now I also tried executing directly with
AR::Base.connection.execute… no luck :frowning:

I dare you to find another hack that can be called the fugliest hack
ever:

if ENV["RAILS_ENV"] == "development"
  created = Time.now.strftime('%Y-%m-%d %H:%M:%S')
  sql = "INSERT INTO estudio_stages ('updated_at', 'estudio_id', 

‘created_at’, ‘stage_id’) VALUES(’#{created}’, #{self.id}, ‘#{created}’,
#{s.id})"
a = %x[sqlite3 #{RAILS_ROOT}/db/development.db “#{sql}”]
self.save!
self.reload
else
self.stages.build :stage_id => s.id
self.save
end

Sigh…