|
1 | 1 | # coding: utf-8 |
2 | 2 |
|
3 | | -from six import raise_from, iteritems |
| 3 | +from six import raise_from |
4 | 4 |
|
5 | 5 | from .defaults import default_dbname, default_username |
6 | 6 | from .exceptions import CatchUpException |
7 | | -from .utils import pg_version_ge |
| 7 | +from .utils import options_string |
8 | 8 |
|
9 | 9 |
|
10 | 10 | class Publication(object): |
@@ -79,21 +79,20 @@ def __init__(self, |
79 | 79 | self.pub = publication |
80 | 80 |
|
81 | 81 | # connection info |
82 | | - conninfo = ( |
83 | | - u"dbname={} user={} host={} port={}" |
84 | | - ).format(self.pub.dbname, |
85 | | - self.pub.username, |
86 | | - self.pub.node.host, |
87 | | - self.pub.node.port) |
| 82 | + conninfo = { |
| 83 | + "dbname": self.pub.dbname, |
| 84 | + "user": self.pub.username, |
| 85 | + "host": self.pub.node.host, |
| 86 | + "port": self.pub.node.port |
| 87 | + } |
88 | 88 |
|
89 | 89 | query = ( |
90 | 90 | "create subscription {} connection '{}' publication {}" |
91 | | - ).format(subname, conninfo, self.pub.name) |
| 91 | + ).format(subname, options_string(**conninfo), self.pub.name) |
92 | 92 |
|
93 | 93 | # additional parameters |
94 | 94 | if kwargs: |
95 | | - params = ','.join('{}={}'.format(k, v) for k, v in iteritems(kwargs)) |
96 | | - query += " with ({})".format(params) |
| 95 | + query += " with ({})".format(options_string(**kwargs)) |
97 | 96 |
|
98 | 97 | node.safe_psql(query, dbname=dbname, username=username) |
99 | 98 |
|
|
0 commit comments