Coldbox 5 Datasource Settings

Coldbox version is 5.0.0+633

Cannot for the life of me get Coldbox to recognize my datasource settings. Here’s what I have in my config/Coldbox.cfc file:

// custom settings
settings = {
mainDataSource = {
type = “SQL”,
name = "myDataSourceNameAsDefinedInCFAdmin"
}
};

And here’s how I’m injecting in my DAO:
property name=‘dsn’ inject=‘coldbox:settings:mainDataSource’;

I continually get the below error:
Messages: The DSL provided was not valid: {JAVACAST={null},REF={null},SCOPE={variables},REQUIRED={true},VALUE={null},DSL={coldbox:settings:mainDataSource},TYPE={any},ARGNAME={},NAME={dsn}}

I’ve seen some other’s having issues. What to do?

It’s coldbox:setting not settings

Luis Majano
CEO
Ortus Solutions, Corp

P/F: 1-888-557-8057

Indeed. Thank you!

Yes, I was stung by this yesterday too… the docs say “settings”. I also was stung by having to use the @ModuleName when injecting datasources as well. While I was used to this DSL for a module’s models, etc. - datasources hadn’t needed this when they had their own setting… now they do.

Anyways - just offering that up for anybody else who may get stuck and not realize it.

Can you point us to the docs so we can fix it please. Thanks

Luis Majano
CEO
Ortus Solutions, Corp

P/F: 1-888-557-8057

Where is that in the docs so I can fix it? Here is the doc page for that is it looks correct to me:

https://coldbox.ortusbooks.com/getting-started/configuration/using-settings#injecting-settings

Copy pasting from the docs, I see this:

coldbox:setting:{key}

and this:

property name=“mysetting” inject=“coldbox:setting:mysetting”;

Also, adding the @modulename bit to inject settings from a module has always been the case and is documented here:

https://coldbox.ortusbooks.com/hmvc/modules/moduleconfig/module-settings#injecting-module-settings

Note, ColdBox no longer has any concept of a thing called a “datasource”. These are just normal settings just like any other setting. You name it what you want and you inject it with the generic rules for injecting settings.

It’s in the Upgrading to CB 5 section under “Datasources Configuration Dropped” section:

Re: @modulename and datasource key - yes, I’m aware of using these items. I was just pointing out that injecting datasources that were configured in ModuleConfig CFCs previously didn’t require the @modulename as they were added to the global datasources setting. I was updating an app with more than a dozen different datasources setup in so many modules and mistakenly thought I could do a global search and replace to change all of my property injections from “coldbox:datasource:mydsn” to “coldbox:setting:mydsn” (however this did not work because of the aforementioned @modulename requirement.)

The requirement was there before, but wasn’t necessary for datasources. I just thought others may run into the same issue of they were migrating from 4.x to 5.x so I pointed it out!

Thanks, I fixed the typo. If you want to contribute your module-specific datasource settings to the parent ColdBox settings struct, use the parentSettings struct. Then you should be able to inject it with the non-module syntax.

Thanks for the tip! It’s all good though, just a slight hiccup in my global search-replace strategy.