ironcamel / Dancer-Plugin-DBIC

DBIx::Class Plugin for Dancer
1 stars 13 forks source link

Extraction of DBICx::Sugar breaks backwards compatibility without notice #18

Open Util opened 9 years ago

Util commented 9 years ago

While developing a Dancer app on two machines with differing versions of Dancer::Plugin::DBIC (0.2100 and 0.2102), I had to patch Sugar.pm to compensate for the difference in expected keys in config.yml. DBICx::Sugar maybe working as designed, but that design does not allow transparent migration to the most reason version of Dancer::Plugin::DBIC.

--- Sugar.pm_real   2015-03-29 04:10:37.000000000 -0500
+++ Sugar.pm    2015-04-25 13:45:44.000000000 -0500
@@ -30,7 +30,7 @@
     } else {
         croak "could not find a config.yml or config.yaml file";
     }
-    return LoadFile($config_path)->{dbicx_sugar};
+    return LoadFile($config_path)->{plugins}{DBIC};
 }

 sub schema {

Also, the system with the older module allows the use of environments/development.yml to supplement config.yml, but the system with the newer module requires its config to be read solely from config.yml. This might be unrelated to the main bug described above; I am new to Dancer development, and might be mis-understanding some component of server setup.

ironcamel commented 9 years ago

The goal of DBICx::Sugar is to be full backwards compatible with Dancer::Plugin::DBIC. I don't really understand why you needed to do the above patch. I only added support for the dbicx_sugar yaml config thing for people that wanted to use DBICx::Sugar outside of Dancer. If you are using Dancer, you should never need a dbicx_sugar thing in your config. The plugin uses the DBICx::Sugar::config function to set the config from the plugin_settings: https://metacpan.org/source/IRONCAMEL/Dancer-Plugin-DBIC-0.2102/lib/Dancer/Plugin/DBIC.pm#L14 . The plugin_settings function loads the config from the Dancer config as normal.