-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version_locations doesn't support directories with spaces (e.g. C:\Program Files\MyApp) #842
Comments
resolution proposal
|
If instead we use a |
I guess the issue is that it's a bit strange to express for windows like paths:
|
yeah it's not going to work with straight up windows paths and neither is colon as a pathsep |
If the user wants to pass a def parse_version_locations(v_l):
if isinstance(v_l, (list, tuple, set)):
return v_l
else:
# simplified version of current approach
return v_l.split(" ")
print(parse_version_locations("/foo /bar"))
# ['/foo', '/bar']
# ok (as currently implemented)
print(parse_version_locations(r"C:\Program Files\foo"))
# ['C:\\Program', 'Files\\foo']
# no es bueno
print(parse_version_locations([r"C:\Program Files\foo"]))
# ['C:\\Program Files\\foo']
# ok
print(parse_version_locations([r"C:\Program Files\foo", r"C:\bar"]))
# ['C:\\Program Files\\foo', 'C:\\bar']
# ok |
what does one put in the alembic.ini file for those? i thought that was the issue here. |
The repro code in the issue report uses c.set_main_option("version_locations", "C:\\Program Files\\MyApp\\MyVersions") so I was suggesting that it be c.set_main_option("version_locations", ["C:\\Program Files\\MyApp\\MyVersions"]) with the corresponding changes in the code that parses it, of course. |
OK so yes we can have set_main_option accept a list, if it doesn't already. i guess the poster didn't indicate "how do i put this in my alembic.ini file", but I think we should address that also. hows that? |
Sure. A list in the .ini file would just be the string JSON representation: """alembic.ini contains:
[alembic]
version_locations=["C:\\Program Files\\foo"]
"""
config = configparser.ConfigParser()
config.read(r"C:\Users\Gord\Desktop\alembic.ini")
ini_string_value = config["alembic"]["version_locations"]
print(ini_string_value) # ["C:\\Program Files\\foo"]
try:
value_to_parse = json.loads(ini_string_value)
except json.decoder.JSONDecodeError:
print("(not valid JSON - use literal)")
value_to_parse = ini_string_value
print(parse_version_locations(value_to_parse))
# ['C:\\Program Files\\foo'] |
Gord Thompson has proposed a fix for this issue in the master branch: Support version_locations paths with spaces https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/2869 |
IMO I don't think json is the most traditional approach for .ini file values, particularly paths as that's what os.pathsep is for. I think sticking with os.pathsep with options to customize for backwards compatibility will be a simpler approach with better backwards compatibility and easier to understand. |
Describe the bug
Space is used a path separator in
version_locations
. As a result, it's not possible to set customversion_locations
to a directory that contains spaces (e.g.C:\Program Files\MyApp
)Expected behavior
Directories with spaces are supported.
To Reproduce
Error
Buggy line: https://github.com/sqlalchemy/alembic/blob/rel_1_6_2/alembic/script/base.py#L140
Versions.
All
Additional context
Have a nice day!
The text was updated successfully, but these errors were encountered: