diff --git a/manifests/server/config_entry.pp b/manifests/server/config_entry.pp index e6460659a2..30142f290b 100644 --- a/manifests/server/config_entry.pp +++ b/manifests/server/config_entry.pp @@ -10,7 +10,7 @@ define postgresql::server::config_entry ( Enum['present', 'absent'] $ensure = 'present', String[1] $key = $name, - Optional[Variant[String[1], Numeric, Array[String[1]]]] $value = undef, + Optional[Variant[String, Numeric, Array[String[1]]]] $value = undef, Stdlib::Absolutepath $path = $postgresql::server::postgresql_conf_path, Optional[String[1]] $comment = undef, String[1] $instance_name = 'main', diff --git a/spec/defines/server/config_entry_spec.rb b/spec/defines/server/config_entry_spec.rb index 243e2ea5e9..810df53e2f 100644 --- a/spec/defines/server/config_entry_spec.rb +++ b/spec/defines/server/config_entry_spec.rb @@ -79,4 +79,19 @@ .that_notifies('Postgresql::Server::Instance::Service[main]') end end + + # Example use case for empty values: using transaction-bound session + # variables, like `SET LOCAL awesome_app.tenant_id = 92834` requires the + # variable to be defined in postgresql.conf and initialised with a default + # value (at least for PostgreSQL 13 and older, possibly also in newer + # versions). The default value can, and sometimes, depending on the + # application, should, be empty. + context 'set a config entry value to the empty string' do + let(:params) { { ensure: 'present', name: 'mydatabase.app_specific_parameter', value: '' } } + + it 'sets value to the empty string' do + expect(subject).to contain_postgresql_conf('mydatabase.app_specific_parameter').with(name: 'mydatabase.app_specific_parameter', + value: '') + end + end end