simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.65k stars 370 forks source link

Drift 2.1.0 : Unrecognized keys: [compact_query_methods] when generate code #2036

Closed zgramming closed 2 years ago

zgramming commented 2 years ago

Describe the bug

Upgrade package from 1.7.1 to 2.1.0, then re-generate code using flutter pub run build_runner build --delete-conflicting-outputs then get error :

PS C:\project_flutter\pik\idf_app_v2> flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 1.6s

[SEVERE]
CheckedFromJsonException
Could not create `DriftOptions`.
Unrecognized keys: [compact_query_methods]; supported keys: [write_from_json_string_constructor, override_hash_and_equals_in_result_sets, skip_verification_code, use_data_class_name_for_companions, use_column_name_as_json_key_when_defined_in_moor_file, generate_connect_constructor, sqlite_modules, sqlite, sql, data_class_to_companions, 
mutable_classes, raw_result_set_data, apply_converters_on_variables, generate_values_in_copy_with, named_parameters, named_parameters_always_required, scoped_dart_components, store_date_time_values_as_text]
pub finished with exit code 78

When I analyze the error, this error is directed at the build.yaml file. This is my build.yaml

# build.yaml. This file is quite powerful, see https://pub.dev/packages/build_config

targets:
  $default:
    builders:
      drift_dev:
        options:
          compact_query_methods: true << this is the problem
          named_parameters: true
          named_parameters_always_required: true

Already see the changelog for breaking change for upgrade Version 1.X into 2.X but the changelog not notice this, because when i generate in version 1.X is totally fine. And in documentation about Builder Option still in available options.

To solve problem, i comment the option compact_query_methods.

simolus3 commented 2 years ago

The option has been removed and always defaults to true now. So you can just remove it from your build.yaml file without any changes.

Thanks for pointing out the missing changelog entries and the outdated documentation! I have updated them to mention this as well.

pavel604 commented 2 years ago

I had the same issue migrating from 1.7.1 to 2.1.0. I got the following error:

[SEVERE] 
CheckedFromJsonException
Could not create `DriftOptions`.
Unrecognized keys: [compact_query_methods, new_sql_code_generation]; supported keys: [write_from_json_string_constructor, override_hash_and_equals_in_result_sets, skip_verification_code, use_data_class_name_for_companions, use_column_name_as_json_key_when_defined_in_moor_file, generate_connect_constructor, sqlite_modules, sqlite, sql, data_class_to_companions, mutable_classes, raw_result_set_data, apply_converters_on_variables, generate_values_in_copy_with, named_parameters, named_parameters_always_required, scoped_dart_components, store_date_time_values_as_text]
pub finished with exit code 78

Removed compact_query_methods and new_sql_code_generation from build.yaml and it worked.