salt.modules.postgres: Quote all extension work

- Fix regressions in tests introduced by @ticosax (nevermind @ticosax i
  also regulary breaks them :p)
- Quote also alters.
This commit is contained in:
Mathieu Le Marec - Pasquet 2014-03-02 10:17:46 +00:00
parent 2bacf994fa
commit b62c680b81
2 changed files with 8 additions and 8 deletions

View File

@ -1249,10 +1249,10 @@ def create_extension(name,
else:
args = []
if schema and _EXTENSION_TO_MOVE in mtdata:
args.append('ALTER EXTENSION {0} SET SCHEMA {1};'.format(
args.append('ALTER EXTENSION "{0}" SET SCHEMA {1};'.format(
name, schema))
if ext_version and _EXTENSION_TO_UPGRADE in mtdata:
args.append('ALTER EXTENSION {0} UPDATE TO {1};'.format(
args.append('ALTER EXTENSION "{0}" UPDATE TO {1};'.format(
name, ext_version))
cmd = ' '.join(args).strip()
if cmd:

View File

@ -621,30 +621,30 @@ class PostgresTestCase(TestCase):
'''
self.assertTrue(postgres.create_extension('foo'))
self.assertTrue(re.match(
'CREATE EXTENSION IF NOT EXISTS foo ;',
'CREATE EXTENSION IF NOT EXISTS "foo" ;',
postgres._psql_prepare_and_run.call_args[0][0][1]))
self.assertTrue(postgres.create_extension(
'foo', schema='a', ext_version='b', from_version='c'))
self.assertTrue(re.match(
'CREATE EXTENSION IF NOT EXISTS foo '
'CREATE EXTENSION IF NOT EXISTS "foo" '
'WITH SCHEMA a VERSION b FROM c ;',
postgres._psql_prepare_and_run.call_args[0][0][1]))
self.assertFalse(postgres.create_extension('foo'))
ret = postgres.create_extension('foo', ext_version='a', schema='b')
self.assertTrue(ret)
self.assertTrue(re.match(
'ALTER EXTENSION foo SET SCHEMA b;'
' ALTER EXTENSION foo UPDATE TO a;',
'ALTER EXTENSION "foo" SET SCHEMA b;'
' ALTER EXTENSION "foo" UPDATE TO a;',
postgres._psql_prepare_and_run.call_args[0][0][1]))
ret = postgres.create_extension('foo', ext_version='a', schema='b')
self.assertTrue(ret)
self.assertTrue(re.match(
'ALTER EXTENSION foo SET SCHEMA b;',
'ALTER EXTENSION "foo" SET SCHEMA b;',
postgres._psql_prepare_and_run.call_args[0][0][1]))
ret = postgres.create_extension('foo', ext_version='a', schema='b')
self.assertTrue(ret)
self.assertTrue(re.match(
'ALTER EXTENSION foo UPDATE TO a;',
'ALTER EXTENSION "foo" UPDATE TO a;',
postgres._psql_prepare_and_run.call_args[0][0][1]))
self.assertFalse(postgres.create_extension(
'foo', ext_version='a', schema='b'))