Skip to content

Conversation

woblavobla
Copy link

Added redmine support and datetime fixes

@rowland
Copy link
Owner

rowland commented Oct 17, 2016

bundle exec rake test Using fb /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/database_statements.rb:13:inexecute': Fb::Error: Column does not belong to referenced table (ActiveRecord::StatementInvalid)
Dynamic SQL Error
SQL error code = -206
Column unknown
NEW.ID
At line 6, column 23
: CREATE TRIGGER N$AUTO_ID_TESTS FOR AUTO_ID_TESTS
ACTIVE BEFORE INSERT
AS
declare variable gen_val bigint;
BEGIN
if (new.ID is null) then
new.ID = next value for auto_id_tests_seq;
else begin
gen_val = gen_id(auto_id_tests_seq, 0);
if (new.ID > gen_val) then
gen_val = gen_id(auto_id_tests_seq, new.ID - gen_val);
end
END
from /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/database_statements.rb:13:in block in execute' from /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/database_statements.rb:121:inblock in translate_and_log'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:472:in block in log' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/notifications/instrumenter.rb:20:ininstrument'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:466:in log' from /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/database_statements.rb:121:intranslate_and_log'
from /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/database_statements.rb:12:in execute' from /Users/brent/src/activerecord-fb-adapter/lib/active_record/connection_adapters/fb/schema_statements.rb:97:increate_table'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/migration.rb:665:in block in method_missing' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/migration.rb:634:inblock in say_with_time'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/2.2.0/benchmark.rb:288:in measure' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/migration.rb:634:insay_with_time'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/migration.rb:654:in method_missing' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/test/schema/schema.rb:94:inblock in <top (required)>'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/schema.rb:41:in instance_eval' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/schema.rb:41:indefine'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/lib/active_record/schema.rb:61:in define' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/test/schema/schema.rb:3:in<top (required)>'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:268:in load' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:268:inblock in load'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:240:in load_dependency' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:268:inload'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/test/cases/helper.rb:161:in load_schema' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activerecord/test/cases/helper.rb:170:in<top (required)>'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:274:in require' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:274:inblock in require'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:240:in load_dependency' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/bundler/gems/rails-f7de6b0254f9/activesupport/lib/active_support/dependencies.rb:274:inrequire'
from /Users/brent/src/activerecord-fb-adapter/test/cases/fb_helper.rb:14:in <top (required)>' from /Users/brent/src/activerecord-fb-adapter/test/cases/add_column_test_fb.rb:2:inrequire'
from /Users/brent/src/activerecord-fb-adapter/test/cases/add_column_test_fb.rb:2:in <top (required)>' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:15:inrequire'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:15:in block in <main>' from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:4:inselect'
from /Users/brent/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:4:in <main>' rake aborted!

when Time
"'#{value.strftime("%m-%d-%Y %H:%M")}'"
when Date
"'#{value.strftime("%m-%d-%Y")}'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the BINDDATE craziness is there for a good reason. In one of my previous PRs, I learned why this is here and explained it in the comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain it here, why binddate is better solution?

end

def rename_table(name, new_name)
fail ActiveRecordError, 'Firebird does not support renaming tables.'
end

def drop_table(name, options = {}) # :nodoc:
super
Copy link
Contributor

@rzane rzane Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the table has a sequence, you can't drop it. You need to drop the sequence first.

Unless I'm missing something, the super should come after the sequence is dropped.

@@ -144,13 +168,19 @@ def remove_column(table_name, column_name, type = nil, options = {})
def change_column(table_name, column_name, type, options = {})
type_sql = type_to_sql(type, *options.values_at(:limit, :precision, :scale))

execute(squish_sql(<<-end_sql))
if type == :text
remove_column table_name, column_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change column is supposed to be a "safe" operation, meaning it won't delete your data. I would say dropping a column without warning would be very unsafe.

unless options[:sequence] == false
sequence_name = options[:sequence] || default_sequence_name(name)
drop_sequence(sequence_name) if sequence_exists?(sequence_name)
end

super
commit_db_transaction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for all of the commit_db_transaction invocations? execute should commit.

@rzane
Copy link
Contributor

rzane commented Oct 17, 2016

Please don't forget to run the Active Record test suite against this PR. There will be plenty of failures, but it should indicate regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants