Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value not set for attributes of type input, select, tree_select, richtext, textarea, checkbox #1653

Open
MBekspert opened this issue Nov 17, 2017 · 3 comments

Comments

@MBekspert
Copy link

@MBekspert MBekspert commented Nov 17, 2017

Infos:

We added object (type text) to the Ticket. Default value set.
We are adding a new ticket. There are two different ways to handle this new field.

  • Used Zammad version: 2.1.0-15095477
  • Used Zammad installation source: package
  • Operating system: Debian 9.2 (4.9.0-4-amd64)
  • Browser + version: Firefox 56.0.2
  • Ticket-ID: #1067567

Expected behavior:

  • when creating a new ticket via email or web the value is set to default value. (any value)
    This effect is an improper triggers and overviews.

Actual behavior:

  • Creating a new ticket via email does not set any value in this field.

Steps to reproduce the behavior:

  • add new object to the ticket, add new ticket via web and via email.

Yes I'm sure this is a bug and no feature request or a general question.

@rlue rlue added this to To do in Workflow Jul 23, 2018
@thorsteneckel thorsteneckel assigned SummerStorm and unassigned rlue Aug 8, 2018
@SummerStorm SummerStorm moved this from To do to In progress in Workflow Aug 14, 2018
@SummerStorm SummerStorm moved this from In progress to CI in Workflow Aug 16, 2018
@SummerStorm SummerStorm moved this from CI to In progress in Workflow Aug 28, 2018
@SummerStorm SummerStorm moved this from In progress to Blocked in Workflow Aug 31, 2018
@thorsteneckel thorsteneckel changed the title Own added object not set when ticket add via email. Default value not set for attributes of type input, select, tree_select, richtext, textarea, checkbox Aug 16, 2019
@thorsteneckel thorsteneckel removed this from Blocked in Workflow Aug 16, 2019
@thorsteneckel thorsteneckel self-assigned this Aug 16, 2019
zammad-sync pushed a commit that referenced this issue Aug 16, 2019
…, select, tree_select, richtext, textarea, checkbox.
zammad-sync pushed a commit that referenced this issue Sep 3, 2019
… type input, select, tree_select, richtext, textarea, checkbox.
@abeluck

This comment has been minimized.

Copy link

@abeluck abeluck commented Sep 4, 2019

I ran into an error related to this fix for this bug when testing develop on my test instance:

Not sure if this is a bug, or just an artifact of running a WIP that is develop, but sharing here just in case..

# bundle exec rails db:migrate
I, [2019-09-04T16:34:00.264931 #22-47398444451260]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "User", "KnowledgeBase::Answer::Translation", "Organization", "Ticket"])
I, [2019-09-04T16:34:00.942238 #22-47398444451260]  INFO -- : Migrating to Issue1653DefaultValueNotSetForSelectInputEtc (20190816091726)
== 20190816091726 Issue1653DefaultValueNotSetForSelectInputEtc: migrating =====
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Attribute not editable!
/opt/zammad/app/models/object_manager/attribute.rb:933:in `check_editable'
/opt/zammad/app/models/object_manager/attribute.rb:353:in `add'
/opt/zammad/db/migrate/20190816091726_issue_1653_default_value_not_set_for_select_input_etc.rb:10:in `block in change'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/relation/delegation.rb:71:in `each'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/db/migrate/20190816091726_issue_1653_default_value_not_set_for_select_input_etc.rb:6:in `change'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:814:in `exec_migration'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:797:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:796:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:977:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/transactions.rb:212:in `transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1343:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `each'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1036:in `up'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1011:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
bin/rails:9:in `<main>'

Caused by:
Attribute not editable!
/opt/zammad/app/models/object_manager/attribute.rb:933:in `check_editable'
/opt/zammad/app/models/object_manager/attribute.rb:353:in `add'
/opt/zammad/db/migrate/20190816091726_issue_1653_default_value_not_set_for_select_input_etc.rb:10:in `block in change'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/relation/delegation.rb:71:in `each'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/db/migrate/20190816091726_issue_1653_default_value_not_set_for_select_input_etc.rb:6:in `change'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:814:in `exec_migration'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:797:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:796:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:977:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/transactions.rb:212:in `transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1343:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `each'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1036:in `up'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1011:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
bin/rails:9:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
@thorsteneckel

This comment has been minimized.

Copy link
Collaborator

@thorsteneckel thorsteneckel commented Sep 4, 2019

Hi @abeluck - thanks a ton for your feedback. This is extremely valuable for us! A follow up fix is currently going through QA.

zammad-sync pushed a commit that referenced this issue Sep 12, 2019
…pe input, select, tree_select, richtext, textarea, checkbox."

This reverts commit 93c5708 and c2bdbe6.
@thorsteneckel

This comment has been minimized.

Copy link
Collaborator

@thorsteneckel thorsteneckel commented Sep 12, 2019

Hey @abeluck - after a longer discussion we had to revert the changes because of the side effects it would introduce (especially on larger systems).

The issue is that a change or introduction of a default value of an attribute will lead to an alter table which will take quite a lot of time on larger systems. Therefore an application based default value (via an ActiveRecord callback) is preferred over a database based.

Anyhow, you should be able to update your test system on develop in about 30 minutes from now.

@zammad zammad locked and limited conversation to collaborators Mar 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.