Skip to content

Commit b30d7e2

Browse files
committed
properly forward schema parameters from replication script
1 parent 7609e0e commit b30d7e2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

scripts/osm2pgsql-replication

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class DBError(Exception):
111111

112112
class DBConnection:
113113

114-
def __init__(self, args):
115-
self.schema = args.middle_schema
114+
def __init__(self, schema, args):
115+
self.schema = schema
116116

117117
# If dbname looks like a conninfo string use it as such
118118
if args.database and any(part in args.database for part in ['=', '://']):
@@ -535,8 +535,10 @@ def update(props, args):
535535

536536
osm2pgsql = [args.osm2pgsql_cmd, '--append', '--slim', '--prefix', args.prefix]
537537
osm2pgsql.extend(args.extra_params)
538-
if args.middle_schema != 'public':
538+
if args.middle_schema:
539539
osm2pgsql.extend(('--middle-schema', args.middle_schema))
540+
if args.schema:
541+
osm2pgsql.extend(('--schema', args.schema))
540542
if args.database:
541543
osm2pgsql.extend(('-d', args.database))
542544
if args.username:
@@ -717,16 +719,16 @@ def main(prog_args=None):
717719
datefmt='%Y-%m-%d %H:%M:%S',
718720
level=max(4 - args.verbose, 1) * 10)
719721

720-
args.middle_schema = args.middle_schema or args.schema or 'public'
722+
prop_table_schema = args.middle_schema or args.schema or 'public'
721723

722-
with DBConnection(args) as db:
724+
with DBConnection(prop_table_schema, args) as db:
723725
if db.table_exists(Osm2pgsqlProperties.PROP_TABLE_NAME):
724726
props = Osm2pgsqlProperties(db)
725727
else:
726728
props = LegacyProperties(db, args.prefix)
727729

728730
if not props.is_updatable:
729-
LOG.fatal(f'osm2pgsql middle table "{args.middle_schema}.{args.prefix}_ways" not found in database "{db.name}". '
731+
LOG.fatal(f'osm2pgsql middle table "{prop_table_schema}.{args.prefix}_ways" not found in database "{db.name}". '
730732
'Database needs to be imported in --slim mode.')
731733
return 1
732734

0 commit comments

Comments
 (0)